home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / expr.c < prev    next >
C/C++ Source or Header  |  1994-07-13  |  315KB  |  10,193 lines

  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2.    Copyright (C) 1988, 1992, 1993, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include "config.h"
  22. #include "machmode.h"
  23. #include "rtl.h"
  24. #include "tree.h"
  25. #include "obstack.h"
  26. #include "flags.h"
  27. #include "regs.h"
  28. #include "function.h"
  29. #include "insn-flags.h"
  30. #include "insn-codes.h"
  31. #include "expr.h"
  32. #include "insn-config.h"
  33. #include "recog.h"
  34. #include "output.h"
  35. #include "typeclass.h"
  36.  
  37. #include "bytecode.h"
  38. #include "bc-opcode.h"
  39. #include "bc-typecd.h"
  40. #include "bc-optab.h"
  41. #include "bc-emit.h"
  42.  
  43.  
  44. #define CEIL(x,y) (((x) + (y) - 1) / (y))
  45.  
  46. /* Decide whether a function's arguments should be processed
  47.    from first to last or from last to first.
  48.  
  49.    They should if the stack and args grow in opposite directions, but
  50.    only if we have push insns.  */
  51.  
  52. #ifdef PUSH_ROUNDING
  53.  
  54. #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
  55. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  56. #endif
  57.  
  58. #endif
  59.  
  60. #ifndef STACK_PUSH_CODE
  61. #ifdef STACK_GROWS_DOWNWARD
  62. #define STACK_PUSH_CODE PRE_DEC
  63. #else
  64. #define STACK_PUSH_CODE PRE_INC
  65. #endif
  66. #endif
  67.  
  68. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  69. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  70.  
  71. /* If this is nonzero, we do not bother generating VOLATILE
  72.    around volatile memory references, and we are willing to
  73.    output indirect addresses.  If cse is to follow, we reject
  74.    indirect addresses so a useful potential cse is generated;
  75.    if it is used only once, instruction combination will produce
  76.    the same indirect address eventually.  */
  77. int cse_not_expected;
  78.  
  79. /* Nonzero to generate code for all the subroutines within an
  80.    expression before generating the upper levels of the expression.
  81.    Nowadays this is never zero.  */
  82. int do_preexpand_calls = 1;
  83.  
  84. /* Number of units that we should eventually pop off the stack.
  85.    These are the arguments to function calls that have already returned.  */
  86. int pending_stack_adjust;
  87.  
  88. /* Nonzero means stack pops must not be deferred, and deferred stack
  89.    pops must not be output.  It is nonzero inside a function call,
  90.    inside a conditional expression, inside a statement expression,
  91.    and in other cases as well.  */
  92. int inhibit_defer_pop;
  93.  
  94. /* A list of all cleanups which belong to the arguments of
  95.    function calls being expanded by expand_call.  */
  96. tree cleanups_this_call;
  97.  
  98. /* When temporaries are created by TARGET_EXPRs, they are created at
  99.    this level of temp_slot_level, so that they can remain allocated
  100.    until no longer needed.  CLEANUP_POINT_EXPRs define the lifetime
  101.    of TARGET_EXPRs.  */
  102. int target_temp_slot_level;
  103.  
  104. /* Nonzero means __builtin_saveregs has already been done in this function.
  105.    The value is the pseudoreg containing the value __builtin_saveregs
  106.    returned.  */
  107. static rtx saveregs_value;
  108.  
  109. /* Similarly for __builtin_apply_args.  */
  110. static rtx apply_args_value;
  111.  
  112. /* This structure is used by move_by_pieces to describe the move to
  113.    be performed.  */
  114.  
  115. struct move_by_pieces
  116. {
  117.   rtx to;
  118.   rtx to_addr;
  119.   int autinc_to;
  120.   int explicit_inc_to;
  121.   rtx from;
  122.   rtx from_addr;
  123.   int autinc_from;
  124.   int explicit_inc_from;
  125.   int len;
  126.   int offset;
  127.   int reverse;
  128. };
  129.  
  130. /* Used to generate bytecodes: keep track of size of local variables,
  131.    as well as depth of arithmetic stack. (Notice that variables are
  132.    stored on the machine's stack, not the arithmetic stack.) */
  133.  
  134. extern int local_vars_size;
  135. extern int stack_depth;
  136. extern int max_stack_depth;
  137. extern struct obstack permanent_obstack;
  138.  
  139.  
  140. static rtx enqueue_insn        PROTO((rtx, rtx));
  141. static int queued_subexp_p    PROTO((rtx));
  142. static void init_queue        PROTO((void));
  143. static void move_by_pieces    PROTO((rtx, rtx, int, int));
  144. static int move_by_pieces_ninsns PROTO((unsigned int, int));
  145. static void move_by_pieces_1    PROTO((rtx (*) (), enum machine_mode,
  146.                        struct move_by_pieces *));
  147. static void store_constructor    PROTO((tree, rtx));
  148. static rtx store_field        PROTO((rtx, int, int, enum machine_mode, tree,
  149.                        enum machine_mode, int, int, int));
  150. static int get_inner_unaligned_p PROTO((tree));
  151. static tree save_noncopied_parts PROTO((tree, tree));
  152. static tree init_noncopied_parts PROTO((tree, tree));
  153. static int safe_from_p        PROTO((rtx, tree));
  154. static int fixed_type_p        PROTO((tree));
  155. static int get_pointer_alignment PROTO((tree, unsigned));
  156. static tree string_constant    PROTO((tree, tree *));
  157. static tree c_strlen        PROTO((tree));
  158. static rtx expand_builtin    PROTO((tree, rtx, rtx,
  159.                        enum machine_mode, int));
  160. static int apply_args_size    PROTO((void));
  161. static int apply_result_size    PROTO((void));
  162. static rtx result_vector    PROTO((int, rtx));
  163. static rtx expand_builtin_apply_args PROTO((void));
  164. static rtx expand_builtin_apply    PROTO((rtx, rtx, rtx));
  165. static void expand_builtin_return PROTO((rtx));
  166. static rtx expand_increment    PROTO((tree, int));
  167. rtx bc_expand_increment        PROTO((struct increment_operator *, tree));
  168. tree bc_runtime_type_code     PROTO((tree));
  169. rtx bc_allocate_local        PROTO((int, int));
  170. void bc_store_memory         PROTO((tree, tree));
  171. tree bc_expand_component_address PROTO((tree));
  172. tree bc_expand_address         PROTO((tree));
  173. void bc_expand_constructor     PROTO((tree));
  174. void bc_adjust_stack         PROTO((int));
  175. tree bc_canonicalize_array_ref    PROTO((tree));
  176. void bc_load_memory        PROTO((tree, tree));
  177. void bc_load_externaddr        PROTO((rtx));
  178. void bc_load_externaddr_id    PROTO((tree, int));
  179. void bc_load_localaddr        PROTO((rtx));
  180. void bc_load_parmaddr        PROTO((rtx));
  181. static void preexpand_calls    PROTO((tree));
  182. static void do_jump_by_parts_greater PROTO((tree, int, rtx, rtx));
  183. static void do_jump_by_parts_greater_rtx PROTO((enum machine_mode, int, rtx, rtx, rtx, rtx));
  184. static void do_jump_by_parts_equality PROTO((tree, rtx, rtx));
  185. static void do_jump_by_parts_equality_rtx PROTO((rtx, rtx, rtx));
  186. static void do_jump_for_compare    PROTO((rtx, rtx, rtx));
  187. static rtx compare        PROTO((tree, enum rtx_code, enum rtx_code));
  188. static rtx do_store_flag    PROTO((tree, rtx, enum machine_mode, int));
  189. static tree defer_cleanups_to    PROTO((tree));
  190. extern void (*interim_eh_hook)    PROTO((tree));
  191.  
  192. /* Record for each mode whether we can move a register directly to or
  193.    from an object of that mode in memory.  If we can't, we won't try
  194.    to use that mode directly when accessing a field of that mode.  */
  195.  
  196. static char direct_load[NUM_MACHINE_MODES];
  197. static char direct_store[NUM_MACHINE_MODES];
  198.  
  199. /* MOVE_RATIO is the number of move instructions that is better than
  200.    a block move.  */
  201.  
  202. #ifndef MOVE_RATIO
  203. #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi) || defined (HAVE_movstrdi) || defined (HAVE_movstrti)
  204. #define MOVE_RATIO 2
  205. #else
  206. /* A value of around 6 would minimize code size; infinity would minimize
  207.    execution time.  */
  208. #define MOVE_RATIO 15
  209. #endif
  210. #endif
  211.  
  212. /* This array records the insn_code of insns to perform block moves.  */
  213. enum insn_code movstr_optab[NUM_MACHINE_MODES];
  214.  
  215. /* SLOW_UNALIGNED_ACCESS is non-zero if unaligned accesses are very slow. */
  216.  
  217. #ifndef SLOW_UNALIGNED_ACCESS
  218. #define SLOW_UNALIGNED_ACCESS 0
  219. #endif
  220.  
  221. /* Register mappings for target machines without register windows.  */
  222. #ifndef INCOMING_REGNO
  223. #define INCOMING_REGNO(OUT) (OUT)
  224. #endif
  225. #ifndef OUTGOING_REGNO
  226. #define OUTGOING_REGNO(IN) (IN)
  227. #endif
  228.  
  229. /* Maps used to convert modes to const, load, and store bytecodes. */
  230. enum bytecode_opcode mode_to_const_map[MAX_MACHINE_MODE];
  231. enum bytecode_opcode mode_to_load_map[MAX_MACHINE_MODE];
  232. enum bytecode_opcode mode_to_store_map[MAX_MACHINE_MODE];
  233.  
  234. /* Initialize maps used to convert modes to const, load, and store
  235.    bytecodes. */
  236. void
  237. bc_init_mode_to_opcode_maps ()
  238. {
  239.   int mode;
  240.  
  241.   for (mode = 0; mode < (int) MAX_MACHINE_MODE; mode++)
  242.     mode_to_const_map[mode] =
  243.       mode_to_load_map[mode] =
  244.     mode_to_store_map[mode] = neverneverland;
  245.       
  246. #define DEF_MODEMAP(SYM, CODE, UCODE, CONST, LOAD, STORE) \
  247.   mode_to_const_map[(int) SYM] = CONST; \
  248.   mode_to_load_map[(int) SYM] = LOAD; \
  249.   mode_to_store_map[(int) SYM] = STORE;
  250.  
  251. #include "modemap.def"
  252. #undef DEF_MODEMAP
  253. }
  254.  
  255. /* This is run once per compilation to set up which modes can be used
  256.    directly in memory and to initialize the block move optab.  */
  257.  
  258. void
  259. init_expr_once ()
  260. {
  261.   rtx insn, pat;
  262.   enum machine_mode mode;
  263.   /* Try indexing by frame ptr and try by stack ptr.
  264.      It is known that on the Convex the stack ptr isn't a valid index.
  265.      With luck, one or the other is valid on any machine.  */
  266.   rtx mem = gen_rtx (MEM, VOIDmode, stack_pointer_rtx);
  267.   rtx mem1 = gen_rtx (MEM, VOIDmode, frame_pointer_rtx);
  268.  
  269.   start_sequence ();
  270.   insn = emit_insn (gen_rtx (SET, 0, 0));
  271.   pat = PATTERN (insn);
  272.  
  273.   for (mode = VOIDmode; (int) mode < NUM_MACHINE_MODES;
  274.        mode = (enum machine_mode) ((int) mode + 1))
  275.     {
  276.       int regno;
  277.       rtx reg;
  278.       int num_clobbers;
  279.  
  280.       direct_load[(int) mode] = direct_store[(int) mode] = 0;
  281.       PUT_MODE (mem, mode);
  282.       PUT_MODE (mem1, mode);
  283.  
  284.       /* See if there is some register that can be used in this mode and
  285.      directly loaded or stored from memory.  */
  286.  
  287.       if (mode != VOIDmode && mode != BLKmode)
  288.     for (regno = 0; regno < FIRST_PSEUDO_REGISTER
  289.          && (direct_load[(int) mode] == 0 || direct_store[(int) mode] == 0);
  290.          regno++)
  291.       {
  292.         if (! HARD_REGNO_MODE_OK (regno, mode))
  293.           continue;
  294.  
  295.         reg = gen_rtx (REG, mode, regno);
  296.  
  297.         SET_SRC (pat) = mem;
  298.         SET_DEST (pat) = reg;
  299.         if (recog (pat, insn, &num_clobbers) >= 0)
  300.           direct_load[(int) mode] = 1;
  301.  
  302.         SET_SRC (pat) = mem1;
  303.         SET_DEST (pat) = reg;
  304.         if (recog (pat, insn, &num_clobbers) >= 0)
  305.           direct_load[(int) mode] = 1;
  306.  
  307.         SET_SRC (pat) = reg;
  308.         SET_DEST (pat) = mem;
  309.         if (recog (pat, insn, &num_clobbers) >= 0)
  310.           direct_store[(int) mode] = 1;
  311.  
  312.         SET_SRC (pat) = reg;
  313.         SET_DEST (pat) = mem1;
  314.         if (recog (pat, insn, &num_clobbers) >= 0)
  315.           direct_store[(int) mode] = 1;
  316.       }
  317.     }
  318.  
  319.   end_sequence ();
  320. }
  321.       
  322. /* This is run at the start of compiling a function.  */
  323.  
  324. void
  325. init_expr ()
  326. {
  327.   init_queue ();
  328.  
  329.   pending_stack_adjust = 0;
  330.   inhibit_defer_pop = 0;
  331.   cleanups_this_call = 0;
  332.   saveregs_value = 0;
  333.   apply_args_value = 0;
  334.   forced_labels = 0;
  335. }
  336.  
  337. /* Save all variables describing the current status into the structure *P.
  338.    This is used before starting a nested function.  */
  339.  
  340. void
  341. save_expr_status (p)
  342.      struct function *p;
  343. {
  344.   /* Instead of saving the postincrement queue, empty it.  */
  345.   emit_queue ();
  346.  
  347.   p->pending_stack_adjust = pending_stack_adjust;
  348.   p->inhibit_defer_pop = inhibit_defer_pop;
  349.   p->cleanups_this_call = cleanups_this_call;
  350.   p->saveregs_value = saveregs_value;
  351.   p->apply_args_value = apply_args_value;
  352.   p->forced_labels = forced_labels;
  353.  
  354.   pending_stack_adjust = 0;
  355.   inhibit_defer_pop = 0;
  356.   cleanups_this_call = 0;
  357.   saveregs_value = 0;
  358.   apply_args_value = 0;
  359.   forced_labels = 0;
  360. }
  361.  
  362. /* Restore all variables describing the current status from the structure *P.
  363.    This is used after a nested function.  */
  364.  
  365. void
  366. restore_expr_status (p)
  367.      struct function *p;
  368. {
  369.   pending_stack_adjust = p->pending_stack_adjust;
  370.   inhibit_defer_pop = p->inhibit_defer_pop;
  371.   cleanups_this_call = p->cleanups_this_call;
  372.   saveregs_value = p->saveregs_value;
  373.   apply_args_value = p->apply_args_value;
  374.   forced_labels = p->forced_labels;
  375. }
  376.  
  377. /* Manage the queue of increment instructions to be output
  378.    for POSTINCREMENT_EXPR expressions, etc.  */
  379.  
  380. static rtx pending_chain;
  381.  
  382. /* Queue up to increment (or change) VAR later.  BODY says how:
  383.    BODY should be the same thing you would pass to emit_insn
  384.    to increment right away.  It will go to emit_insn later on.
  385.  
  386.    The value is a QUEUED expression to be used in place of VAR
  387.    where you want to guarantee the pre-incrementation value of VAR.  */
  388.  
  389. static rtx
  390. enqueue_insn (var, body)
  391.      rtx var, body;
  392. {
  393.   pending_chain = gen_rtx (QUEUED, GET_MODE (var),
  394.                var, NULL_RTX, NULL_RTX, body, pending_chain);
  395.   return pending_chain;
  396. }
  397.  
  398. /* Use protect_from_queue to convert a QUEUED expression
  399.    into something that you can put immediately into an instruction.
  400.    If the queued incrementation has not happened yet,
  401.    protect_from_queue returns the variable itself.
  402.    If the incrementation has happened, protect_from_queue returns a temp
  403.    that contains a copy of the old value of the variable.
  404.  
  405.    Any time an rtx which might possibly be a QUEUED is to be put
  406.    into an instruction, it must be passed through protect_from_queue first.
  407.    QUEUED expressions are not meaningful in instructions.
  408.  
  409.    Do not pass a value through protect_from_queue and then hold
  410.    on to it for a while before putting it in an instruction!
  411.    If the queue is flushed in between, incorrect code will result.  */
  412.  
  413. rtx
  414. protect_from_queue (x, modify)
  415.      register rtx x;
  416.      int modify;
  417. {
  418.   register RTX_CODE code = GET_CODE (x);
  419.  
  420. #if 0  /* A QUEUED can hang around after the queue is forced out.  */
  421.   /* Shortcut for most common case.  */
  422.   if (pending_chain == 0)
  423.     return x;
  424. #endif
  425.  
  426.   if (code != QUEUED)
  427.     {
  428.       /* A special hack for read access to (MEM (QUEUED ...)) to facilitate
  429.      use of autoincrement.  Make a copy of the contents of the memory
  430.      location rather than a copy of the address, but not if the value is
  431.      of mode BLKmode.  Don't modify X in place since it might be
  432.      shared.  */
  433.       if (code == MEM && GET_MODE (x) != BLKmode
  434.       && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
  435.     {
  436.       register rtx y = XEXP (x, 0);
  437.       register rtx new = gen_rtx (MEM, GET_MODE (x), QUEUED_VAR (y));
  438.  
  439.       MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x);
  440.       RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
  441.       MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x);
  442.  
  443.       if (QUEUED_INSN (y))
  444.         {
  445.           register rtx temp = gen_reg_rtx (GET_MODE (new));
  446.           emit_insn_before (gen_move_insn (temp, new),
  447.                 QUEUED_INSN (y));
  448.           return temp;
  449.         }
  450.       return new;
  451.     }
  452.       /* Otherwise, recursively protect the subexpressions of all
  453.      the kinds of rtx's that can contain a QUEUED.  */
  454.       if (code == MEM)
  455.     {
  456.       rtx tem = protect_from_queue (XEXP (x, 0), 0);
  457.       if (tem != XEXP (x, 0))
  458.         {
  459.           x = copy_rtx (x);
  460.           XEXP (x, 0) = tem;
  461.         }
  462.     }
  463.       else if (code == PLUS || code == MULT)
  464.     {
  465.       rtx new0 = protect_from_queue (XEXP (x, 0), 0);
  466.       rtx new1 = protect_from_queue (XEXP (x, 1), 0);
  467.       if (new0 != XEXP (x, 0) || new1 != XEXP (x, 1))
  468.         {
  469.           x = copy_rtx (x);
  470.           XEXP (x, 0) = new0;
  471.           XEXP (x, 1) = new1;
  472.         }
  473.     }
  474.       return x;
  475.     }
  476.   /* If the increment has not happened, use the variable itself.  */
  477.   if (QUEUED_INSN (x) == 0)
  478.     return QUEUED_VAR (x);
  479.   /* If the increment has happened and a pre-increment copy exists,
  480.      use that copy.  */
  481.   if (QUEUED_COPY (x) != 0)
  482.     return QUEUED_COPY (x);
  483.   /* The increment has happened but we haven't set up a pre-increment copy.
  484.      Set one up now, and use it.  */
  485.   QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
  486.   emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
  487.             QUEUED_INSN (x));
  488.   return QUEUED_COPY (x);
  489. }
  490.  
  491. /* Return nonzero if X contains a QUEUED expression:
  492.    if it contains anything that will be altered by a queued increment.
  493.    We handle only combinations of MEM, PLUS, MINUS and MULT operators
  494.    since memory addresses generally contain only those.  */
  495.  
  496. static int
  497. queued_subexp_p (x)
  498.      rtx x;
  499. {
  500.   register enum rtx_code code = GET_CODE (x);
  501.   switch (code)
  502.     {
  503.     case QUEUED:
  504.       return 1;
  505.     case MEM:
  506.       return queued_subexp_p (XEXP (x, 0));
  507.     case MULT:
  508.     case PLUS:
  509.     case MINUS:
  510.       return queued_subexp_p (XEXP (x, 0))
  511.     || queued_subexp_p (XEXP (x, 1));
  512.     }
  513.   return 0;
  514. }
  515.  
  516. /* Perform all the pending incrementations.  */
  517.  
  518. void
  519. emit_queue ()
  520. {
  521.   register rtx p;
  522.   while (p = pending_chain)
  523.     {
  524.       QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
  525.       pending_chain = QUEUED_NEXT (p);
  526.     }
  527. }
  528.  
  529. static void
  530. init_queue ()
  531. {
  532.   if (pending_chain)
  533.     abort ();
  534. }
  535.  
  536. /* Copy data from FROM to TO, where the machine modes are not the same.
  537.    Both modes may be integer, or both may be floating.
  538.    UNSIGNEDP should be nonzero if FROM is an unsigned type.
  539.    This causes zero-extension instead of sign-extension.  */
  540.  
  541. void
  542. convert_move (to, from, unsignedp)
  543.      register rtx to, from;
  544.      int unsignedp;
  545. {
  546.   enum machine_mode to_mode = GET_MODE (to);
  547.   enum machine_mode from_mode = GET_MODE (from);
  548.   int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
  549.   int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
  550.   enum insn_code code;
  551.   rtx libcall;
  552.  
  553.   /* rtx code for making an equivalent value.  */
  554.   enum rtx_code equiv_code = (unsignedp ? ZERO_EXTEND : SIGN_EXTEND);
  555.  
  556.   to = protect_from_queue (to, 1);
  557.   from = protect_from_queue (from, 0);
  558.  
  559.   if (to_real != from_real)
  560.     abort ();
  561.  
  562.   /* If FROM is a SUBREG that indicates that we have already done at least
  563.      the required extension, strip it.  We don't handle such SUBREGs as
  564.      TO here.  */
  565.  
  566.   if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from)
  567.       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (from)))
  568.       >= GET_MODE_SIZE (to_mode))
  569.       && SUBREG_PROMOTED_UNSIGNED_P (from) == unsignedp)
  570.     from = gen_lowpart (to_mode, from), from_mode = to_mode;
  571.  
  572.   if (GET_CODE (to) == SUBREG && SUBREG_PROMOTED_VAR_P (to))
  573.     abort ();
  574.  
  575.   if (to_mode == from_mode
  576.       || (from_mode == VOIDmode && CONSTANT_P (from)))
  577.     {
  578.       emit_move_insn (to, from);
  579.       return;
  580.     }
  581.  
  582.   if (to_real)
  583.     {
  584.       rtx value;
  585.  
  586. #ifdef HAVE_extendqfhf2
  587.       if (HAVE_extendqfsf2 && from_mode == QFmode && to_mode == HFmode)
  588.     {
  589.       emit_unop_insn (CODE_FOR_extendqfsf2, to, from, UNKNOWN);
  590.       return;
  591.     }
  592. #endif
  593. #ifdef HAVE_extendqfsf2
  594.       if (HAVE_extendqfsf2 && from_mode == QFmode && to_mode == SFmode)
  595.     {
  596.       emit_unop_insn (CODE_FOR_extendqfsf2, to, from, UNKNOWN);
  597.       return;
  598.     }
  599. #endif
  600. #ifdef HAVE_extendqfdf2
  601.       if (HAVE_extendqfdf2 && from_mode == QFmode && to_mode == DFmode)
  602.     {
  603.       emit_unop_insn (CODE_FOR_extendqfdf2, to, from, UNKNOWN);
  604.       return;
  605.     }
  606. #endif
  607. #ifdef HAVE_extendqfxf2
  608.       if (HAVE_extendqfxf2 && from_mode == QFmode && to_mode == XFmode)
  609.     {
  610.       emit_unop_insn (CODE_FOR_extendqfxf2, to, from, UNKNOWN);
  611.       return;
  612.     }
  613. #endif
  614. #ifdef HAVE_extendqftf2
  615.       if (HAVE_extendqftf2 && from_mode == QFmode && to_mode == TFmode)
  616.     {
  617.       emit_unop_insn (CODE_FOR_extendqftf2, to, from, UNKNOWN);
  618.       return;
  619.     }
  620. #endif
  621.  
  622. #ifdef HAVE_extendhftqf2
  623.       if (HAVE_extendhftqf2 && from_mode == HFmode && to_mode == TQFmode)
  624.     {
  625.       emit_unop_insn (CODE_FOR_extendhftqf2, to, from, UNKNOWN);
  626.       return;
  627.     }
  628. #endif
  629.  
  630. #ifdef HAVE_extendhfsf2
  631.       if (HAVE_extendhfsf2 && from_mode == HFmode && to_mode == SFmode)
  632.     {
  633.       emit_unop_insn (CODE_FOR_extendhfsf2, to, from, UNKNOWN);
  634.       return;
  635.     }
  636. #endif
  637. #ifdef HAVE_extendhfdf2
  638.       if (HAVE_extendhfdf2 && from_mode == HFmode && to_mode == DFmode)
  639.     {
  640.       emit_unop_insn (CODE_FOR_extendhfdf2, to, from, UNKNOWN);
  641.       return;
  642.     }
  643. #endif
  644. #ifdef HAVE_extendhfxf2
  645.       if (HAVE_extendhfxf2 && from_mode == HFmode && to_mode == XFmode)
  646.     {
  647.       emit_unop_insn (CODE_FOR_extendhfxf2, to, from, UNKNOWN);
  648.       return;
  649.     }
  650. #endif
  651. #ifdef HAVE_extendhftf2
  652.       if (HAVE_extendhftf2 && from_mode == HFmode && to_mode == TFmode)
  653.     {
  654.       emit_unop_insn (CODE_FOR_extendhftf2, to, from, UNKNOWN);
  655.       return;
  656.     }
  657. #endif
  658.  
  659. #ifdef HAVE_extendsfdf2
  660.       if (HAVE_extendsfdf2 && from_mode == SFmode && to_mode == DFmode)
  661.     {
  662.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  663.       return;
  664.     }
  665. #endif
  666. #ifdef HAVE_extendsfxf2
  667.       if (HAVE_extendsfxf2 && from_mode == SFmode && to_mode == XFmode)
  668.     {
  669.       emit_unop_insn (CODE_FOR_extendsfxf2, to, from, UNKNOWN);
  670.       return;
  671.     }
  672. #endif
  673. #ifdef HAVE_extendsftf2
  674.       if (HAVE_extendsftf2 && from_mode == SFmode && to_mode == TFmode)
  675.     {
  676.       emit_unop_insn (CODE_FOR_extendsftf2, to, from, UNKNOWN);
  677.       return;
  678.     }
  679. #endif
  680. #ifdef HAVE_extenddfxf2
  681.       if (HAVE_extenddfxf2 && from_mode == DFmode && to_mode == XFmode)
  682.     {
  683.       emit_unop_insn (CODE_FOR_extenddfxf2, to, from, UNKNOWN);
  684.       return;
  685.     }
  686. #endif
  687. #ifdef HAVE_extenddftf2
  688.       if (HAVE_extenddftf2 && from_mode == DFmode && to_mode == TFmode)
  689.     {
  690.       emit_unop_insn (CODE_FOR_extenddftf2, to, from, UNKNOWN);
  691.       return;
  692.     }
  693. #endif
  694.  
  695. #ifdef HAVE_trunchfqf2
  696.       if (HAVE_trunchfqf2 && from_mode == HFmode && to_mode == QFmode)
  697.     {
  698.       emit_unop_insn (CODE_FOR_trunchfqf2, to, from, UNKNOWN);
  699.       return;
  700.     }
  701. #endif
  702. #ifdef HAVE_truncsfqf2
  703.       if (HAVE_truncsfqf2 && from_mode == SFmode && to_mode == QFmode)
  704.     {
  705.       emit_unop_insn (CODE_FOR_truncsfqf2, to, from, UNKNOWN);
  706.       return;
  707.     }
  708. #endif
  709. #ifdef HAVE_truncdfqf2
  710.       if (HAVE_truncdfqf2 && from_mode == DFmode && to_mode == QFmode)
  711.     {
  712.       emit_unop_insn (CODE_FOR_truncdfqf2, to, from, UNKNOWN);
  713.       return;
  714.     }
  715. #endif
  716. #ifdef HAVE_truncxfqf2
  717.       if (HAVE_truncxfqf2 && from_mode == XFmode && to_mode == QFmode)
  718.     {
  719.       emit_unop_insn (CODE_FOR_truncxfqf2, to, from, UNKNOWN);
  720.       return;
  721.     }
  722. #endif
  723. #ifdef HAVE_trunctfqf2
  724.       if (HAVE_trunctfqf2 && from_mode == TFmode && to_mode == QFmode)
  725.     {
  726.       emit_unop_insn (CODE_FOR_trunctfqf2, to, from, UNKNOWN);
  727.       return;
  728.     }
  729. #endif
  730.  
  731. #ifdef HAVE_trunctqfhf2
  732.       if (HAVE_trunctqfhf2 && from_mode == TQFmode && to_mode == HFmode)
  733.     {
  734.       emit_unop_insn (CODE_FOR_trunctqfhf2, to, from, UNKNOWN);
  735.       return;
  736.     }
  737. #endif
  738. #ifdef HAVE_truncsfhf2
  739.       if (HAVE_truncsfhf2 && from_mode == SFmode && to_mode == HFmode)
  740.     {
  741.       emit_unop_insn (CODE_FOR_truncsfhf2, to, from, UNKNOWN);
  742.       return;
  743.     }
  744. #endif
  745. #ifdef HAVE_truncdfhf2
  746.       if (HAVE_truncdfhf2 && from_mode == DFmode && to_mode == HFmode)
  747.     {
  748.       emit_unop_insn (CODE_FOR_truncdfhf2, to, from, UNKNOWN);
  749.       return;
  750.     }
  751. #endif
  752. #ifdef HAVE_truncxfhf2
  753.       if (HAVE_truncxfhf2 && from_mode == XFmode && to_mode == HFmode)
  754.     {
  755.       emit_unop_insn (CODE_FOR_truncxfhf2, to, from, UNKNOWN);
  756.       return;
  757.     }
  758. #endif
  759. #ifdef HAVE_trunctfhf2
  760.       if (HAVE_trunctfhf2 && from_mode == TFmode && to_mode == HFmode)
  761.     {
  762.       emit_unop_insn (CODE_FOR_trunctfhf2, to, from, UNKNOWN);
  763.       return;
  764.     }
  765. #endif
  766. #ifdef HAVE_truncdfsf2
  767.       if (HAVE_truncdfsf2 && from_mode == DFmode && to_mode == SFmode)
  768.     {
  769.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  770.       return;
  771.     }
  772. #endif
  773. #ifdef HAVE_truncxfsf2
  774.       if (HAVE_truncxfsf2 && from_mode == XFmode && to_mode == SFmode)
  775.     {
  776.       emit_unop_insn (CODE_FOR_truncxfsf2, to, from, UNKNOWN);
  777.       return;
  778.     }
  779. #endif
  780. #ifdef HAVE_trunctfsf2
  781.       if (HAVE_trunctfsf2 && from_mode == TFmode && to_mode == SFmode)
  782.     {
  783.       emit_unop_insn (CODE_FOR_trunctfsf2, to, from, UNKNOWN);
  784.       return;
  785.     }
  786. #endif
  787. #ifdef HAVE_truncxfdf2
  788.       if (HAVE_truncxfdf2 && from_mode == XFmode && to_mode == DFmode)
  789.     {
  790.       emit_unop_insn (CODE_FOR_truncxfdf2, to, from, UNKNOWN);
  791.       return;
  792.     }
  793. #endif
  794. #ifdef HAVE_trunctfdf2
  795.       if (HAVE_trunctfdf2 && from_mode == TFmode && to_mode == DFmode)
  796.     {
  797.       emit_unop_insn (CODE_FOR_trunctfdf2, to, from, UNKNOWN);
  798.       return;
  799.     }
  800. #endif
  801.  
  802.       libcall = (rtx) 0;
  803.       switch (from_mode)
  804.     {
  805.     case SFmode:
  806.       switch (to_mode)
  807.         {
  808.         case DFmode:
  809.           libcall = extendsfdf2_libfunc;
  810.           break;
  811.  
  812.         case XFmode:
  813.           libcall = extendsfxf2_libfunc;
  814.           break;
  815.  
  816.         case TFmode:
  817.           libcall = extendsftf2_libfunc;
  818.           break;
  819.         }
  820.       break;
  821.  
  822.     case DFmode:
  823.       switch (to_mode)
  824.         {
  825.         case SFmode:
  826.           libcall = truncdfsf2_libfunc;
  827.           break;
  828.  
  829.         case XFmode:
  830.           libcall = extenddfxf2_libfunc;
  831.           break;
  832.  
  833.         case TFmode:
  834.           libcall = extenddftf2_libfunc;
  835.           break;
  836.         }
  837.       break;
  838.  
  839.     case XFmode:
  840.       switch (to_mode)
  841.         {
  842.         case SFmode:
  843.           libcall = truncxfsf2_libfunc;
  844.           break;
  845.  
  846.         case DFmode:
  847.           libcall = truncxfdf2_libfunc;
  848.           break;
  849.         }
  850.       break;
  851.  
  852.     case TFmode:
  853.       switch (to_mode)
  854.         {
  855.         case SFmode:
  856.           libcall = trunctfsf2_libfunc;
  857.           break;
  858.  
  859.         case DFmode:
  860.           libcall = trunctfdf2_libfunc;
  861.           break;
  862.         }
  863.       break;
  864.     }
  865.  
  866.       if (libcall == (rtx) 0)
  867.     /* This conversion is not implemented yet.  */
  868.     abort ();
  869.  
  870.       value = emit_library_call_value (libcall, NULL_RTX, 1, to_mode,
  871.                        1, from, from_mode);
  872.       emit_move_insn (to, value);
  873.       return;
  874.     }
  875.  
  876.   /* Now both modes are integers.  */
  877.  
  878.   /* Handle expanding beyond a word.  */
  879.   if (GET_MODE_BITSIZE (from_mode) < GET_MODE_BITSIZE (to_mode)
  880.       && GET_MODE_BITSIZE (to_mode) > BITS_PER_WORD)
  881.     {
  882.       rtx insns;
  883.       rtx lowpart;
  884.       rtx fill_value;
  885.       rtx lowfrom;
  886.       int i;
  887.       enum machine_mode lowpart_mode;
  888.       int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD);
  889.  
  890.       /* Try converting directly if the insn is supported.  */
  891.       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
  892.       != CODE_FOR_nothing)
  893.     {
  894.       /* If FROM is a SUBREG, put it into a register.  Do this
  895.          so that we always generate the same set of insns for
  896.          better cse'ing; if an intermediate assignment occurred,
  897.          we won't be doing the operation directly on the SUBREG.  */
  898.       if (optimize > 0 && GET_CODE (from) == SUBREG)
  899.         from = force_reg (from_mode, from);
  900.       emit_unop_insn (code, to, from, equiv_code);
  901.       return;
  902.     }
  903.       /* Next, try converting via full word.  */
  904.       else if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD
  905.            && ((code = can_extend_p (to_mode, word_mode, unsignedp))
  906.            != CODE_FOR_nothing))
  907.     {
  908.       if (GET_CODE (to) == REG)
  909.         emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  910.       convert_move (gen_lowpart (word_mode, to), from, unsignedp);
  911.       emit_unop_insn (code, to,
  912.               gen_lowpart (word_mode, to), equiv_code);
  913.       return;
  914.     }
  915.  
  916.       /* No special multiword conversion insn; do it by hand.  */
  917.       start_sequence ();
  918.  
  919.       /* Get a copy of FROM widened to a word, if necessary.  */
  920.       if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD)
  921.     lowpart_mode = word_mode;
  922.       else
  923.     lowpart_mode = from_mode;
  924.  
  925.       lowfrom = convert_to_mode (lowpart_mode, from, unsignedp);
  926.  
  927.       lowpart = gen_lowpart (lowpart_mode, to);
  928.       emit_move_insn (lowpart, lowfrom);
  929.  
  930.       /* Compute the value to put in each remaining word.  */
  931.       if (unsignedp)
  932.     fill_value = const0_rtx;
  933.       else
  934.     {
  935. #ifdef HAVE_slt
  936.       if (HAVE_slt
  937.           && insn_operand_mode[(int) CODE_FOR_slt][0] == word_mode
  938.           && STORE_FLAG_VALUE == -1)
  939.         {
  940.           emit_cmp_insn (lowfrom, const0_rtx, NE, NULL_RTX,
  941.                  lowpart_mode, 0, 0);
  942.           fill_value = gen_reg_rtx (word_mode);
  943.           emit_insn (gen_slt (fill_value));
  944.         }
  945.       else
  946. #endif
  947.         {
  948.           fill_value
  949.         = expand_shift (RSHIFT_EXPR, lowpart_mode, lowfrom,
  950.                 size_int (GET_MODE_BITSIZE (lowpart_mode) - 1),
  951.                 NULL_RTX, 0);
  952.           fill_value = convert_to_mode (word_mode, fill_value, 1);
  953.         }
  954.     }
  955.  
  956.       /* Fill the remaining words.  */
  957.       for (i = GET_MODE_SIZE (lowpart_mode) / UNITS_PER_WORD; i < nwords; i++)
  958.     {
  959.       int index = (WORDS_BIG_ENDIAN ? nwords - i - 1 : i);
  960.       rtx subword = operand_subword (to, index, 1, to_mode);
  961.  
  962.       if (subword == 0)
  963.         abort ();
  964.  
  965.       if (fill_value != subword)
  966.         emit_move_insn (subword, fill_value);
  967.     }
  968.  
  969.       insns = get_insns ();
  970.       end_sequence ();
  971.  
  972.       emit_no_conflict_block (insns, to, from, NULL_RTX,
  973.                   gen_rtx (equiv_code, to_mode, copy_rtx (from)));
  974.       return;
  975.     }
  976.  
  977.   /* Truncating multi-word to a word or less.  */
  978.   if (GET_MODE_BITSIZE (from_mode) > BITS_PER_WORD
  979.       && GET_MODE_BITSIZE (to_mode) <= BITS_PER_WORD)
  980.     {
  981.       if (!((GET_CODE (from) == MEM
  982.          && ! MEM_VOLATILE_P (from)
  983.          && direct_load[(int) to_mode]
  984.          && ! mode_dependent_address_p (XEXP (from, 0)))
  985.         || GET_CODE (from) == REG
  986.         || GET_CODE (from) == SUBREG))
  987.     from = force_reg (from_mode, from);
  988.       convert_move (to, gen_lowpart (word_mode, from), 0);
  989.       return;
  990.     }
  991.  
  992.   /* Handle pointer conversion */            /* SPEE 900220 */
  993.   if (to_mode == PSImode)
  994.     {
  995.       if (from_mode != SImode)
  996.     from = convert_to_mode (SImode, from, unsignedp);
  997.  
  998. #ifdef HAVE_truncsipsi2
  999.       if (HAVE_truncsipsi2)
  1000.     {
  1001.       emit_unop_insn (CODE_FOR_truncsipsi2, to, from, UNKNOWN);
  1002.       return;
  1003.     }
  1004. #endif /* HAVE_truncsipsi2 */
  1005.       abort ();
  1006.     }
  1007.  
  1008.   if (from_mode == PSImode)
  1009.     {
  1010.       if (to_mode != SImode)
  1011.     {
  1012.       from = convert_to_mode (SImode, from, unsignedp);
  1013.       from_mode = SImode;
  1014.     }
  1015.       else
  1016.     {
  1017. #ifdef HAVE_extendpsisi2
  1018.       if (HAVE_extendpsisi2)
  1019.         {
  1020.           emit_unop_insn (CODE_FOR_extendpsisi2, to, from, UNKNOWN);
  1021.           return;
  1022.         }
  1023. #endif /* HAVE_extendpsisi2 */
  1024.       abort ();
  1025.     }
  1026.     }
  1027.  
  1028.   /* Now follow all the conversions between integers
  1029.      no more than a word long.  */
  1030.  
  1031.   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
  1032.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
  1033.       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
  1034.                 GET_MODE_BITSIZE (from_mode)))
  1035.     {
  1036.       if (!((GET_CODE (from) == MEM
  1037.          && ! MEM_VOLATILE_P (from)
  1038.          && direct_load[(int) to_mode]
  1039.          && ! mode_dependent_address_p (XEXP (from, 0)))
  1040.         || GET_CODE (from) == REG
  1041.         || GET_CODE (from) == SUBREG))
  1042.     from = force_reg (from_mode, from);
  1043.       emit_move_insn (to, gen_lowpart (to_mode, from));
  1044.       return;
  1045.     }
  1046.  
  1047.   /* Handle extension.  */
  1048.   if (GET_MODE_BITSIZE (to_mode) > GET_MODE_BITSIZE (from_mode))
  1049.     {
  1050.       /* Convert directly if that works.  */
  1051.       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
  1052.       != CODE_FOR_nothing)
  1053.     {
  1054.       /* If FROM is a SUBREG, put it into a register.  Do this
  1055.          so that we always generate the same set of insns for
  1056.          better cse'ing; if an intermediate assignment occurred,
  1057.          we won't be doing the operation directly on the SUBREG.  */
  1058.       if (optimize > 0 && GET_CODE (from) == SUBREG)
  1059.         from = force_reg (from_mode, from);
  1060.       emit_unop_insn (code, to, from, equiv_code);
  1061.       return;
  1062.     }
  1063.       else
  1064.     {
  1065.       enum machine_mode intermediate;
  1066.  
  1067.       /* Search for a mode to convert via.  */
  1068.       for (intermediate = from_mode; intermediate != VOIDmode;
  1069.            intermediate = GET_MODE_WIDER_MODE (intermediate))
  1070.         if (((can_extend_p (to_mode, intermediate, unsignedp)
  1071.           != CODE_FOR_nothing)
  1072.          || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate)
  1073.              && TRULY_NOOP_TRUNCATION (to_mode, intermediate)))
  1074.         && (can_extend_p (intermediate, from_mode, unsignedp)
  1075.             != CODE_FOR_nothing))
  1076.           {
  1077.         convert_move (to, convert_to_mode (intermediate, from,
  1078.                            unsignedp), unsignedp);
  1079.         return;
  1080.           }
  1081.  
  1082.       /* No suitable intermediate mode.  */
  1083.       abort ();
  1084.     }
  1085.     }
  1086.  
  1087.   /* Support special truncate insns for certain modes.  */ 
  1088.  
  1089.   if (from_mode == DImode && to_mode == SImode)
  1090.     {
  1091. #ifdef HAVE_truncdisi2
  1092.       if (HAVE_truncdisi2)
  1093.     {
  1094.       emit_unop_insn (CODE_FOR_truncdisi2, to, from, UNKNOWN);
  1095.       return;
  1096.     }
  1097. #endif
  1098.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1099.       return;
  1100.     }
  1101.  
  1102.   if (from_mode == DImode && to_mode == HImode)
  1103.     {
  1104. #ifdef HAVE_truncdihi2
  1105.       if (HAVE_truncdihi2)
  1106.     {
  1107.       emit_unop_insn (CODE_FOR_truncdihi2, to, from, UNKNOWN);
  1108.       return;
  1109.     }
  1110. #endif
  1111.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1112.       return;
  1113.     }
  1114.  
  1115.   if (from_mode == DImode && to_mode == QImode)
  1116.     {
  1117. #ifdef HAVE_truncdiqi2
  1118.       if (HAVE_truncdiqi2)
  1119.     {
  1120.       emit_unop_insn (CODE_FOR_truncdiqi2, to, from, UNKNOWN);
  1121.       return;
  1122.     }
  1123. #endif
  1124.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1125.       return;
  1126.     }
  1127.  
  1128.   if (from_mode == SImode && to_mode == HImode)
  1129.     {
  1130. #ifdef HAVE_truncsihi2
  1131.       if (HAVE_truncsihi2)
  1132.     {
  1133.       emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
  1134.       return;
  1135.     }
  1136. #endif
  1137.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1138.       return;
  1139.     }
  1140.  
  1141.   if (from_mode == SImode && to_mode == QImode)
  1142.     {
  1143. #ifdef HAVE_truncsiqi2
  1144.       if (HAVE_truncsiqi2)
  1145.     {
  1146.       emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
  1147.       return;
  1148.     }
  1149. #endif
  1150.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1151.       return;
  1152.     }
  1153.  
  1154.   if (from_mode == HImode && to_mode == QImode)
  1155.     {
  1156. #ifdef HAVE_trunchiqi2
  1157.       if (HAVE_trunchiqi2)
  1158.     {
  1159.       emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
  1160.       return;
  1161.     }
  1162. #endif
  1163.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1164.       return;
  1165.     }
  1166.  
  1167.   /* Handle truncation of volatile memrefs, and so on;
  1168.      the things that couldn't be truncated directly,
  1169.      and for which there was no special instruction.  */
  1170.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode))
  1171.     {
  1172.       rtx temp = force_reg (to_mode, gen_lowpart (to_mode, from));
  1173.       emit_move_insn (to, temp);
  1174.       return;
  1175.     }
  1176.  
  1177.   /* Mode combination is not recognized.  */
  1178.   abort ();
  1179. }
  1180.  
  1181. /* Return an rtx for a value that would result
  1182.    from converting X to mode MODE.
  1183.    Both X and MODE may be floating, or both integer.
  1184.    UNSIGNEDP is nonzero if X is an unsigned value.
  1185.    This can be done by referring to a part of X in place
  1186.    or by copying to a new temporary with conversion.
  1187.  
  1188.    This function *must not* call protect_from_queue
  1189.    except when putting X into an insn (in which case convert_move does it).  */
  1190.  
  1191. rtx
  1192. convert_to_mode (mode, x, unsignedp)
  1193.      enum machine_mode mode;
  1194.      rtx x;
  1195.      int unsignedp;
  1196. {
  1197.   return convert_modes (mode, VOIDmode, x, unsignedp);
  1198. }
  1199.  
  1200. /* Return an rtx for a value that would result
  1201.    from converting X from mode OLDMODE to mode MODE.
  1202.    Both modes may be floating, or both integer.
  1203.    UNSIGNEDP is nonzero if X is an unsigned value.
  1204.  
  1205.    This can be done by referring to a part of X in place
  1206.    or by copying to a new temporary with conversion.
  1207.  
  1208.    You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode.
  1209.  
  1210.    This function *must not* call protect_from_queue
  1211.    except when putting X into an insn (in which case convert_move does it).  */
  1212.  
  1213. rtx
  1214. convert_modes (mode, oldmode, x, unsignedp)
  1215.      enum machine_mode mode, oldmode;
  1216.      rtx x;
  1217.      int unsignedp;
  1218. {
  1219.   register rtx temp;
  1220.  
  1221.   /* If FROM is a SUBREG that indicates that we have already done at least
  1222.      the required extension, strip it.  */
  1223.  
  1224.   if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x)
  1225.       && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode)
  1226.       && SUBREG_PROMOTED_UNSIGNED_P (x) == unsignedp)
  1227.     x = gen_lowpart (mode, x);
  1228.  
  1229.   if (GET_MODE (x) != VOIDmode)
  1230.     oldmode = GET_MODE (x);
  1231.  
  1232.   if (mode == oldmode)
  1233.     return x;
  1234.  
  1235.   /* There is one case that we must handle specially: If we are converting
  1236.      a CONST_INT into a mode whose size is twice HOST_BITS_PER_WIDE_INT and
  1237.      we are to interpret the constant as unsigned, gen_lowpart will do
  1238.      the wrong if the constant appears negative.  What we want to do is
  1239.      make the high-order word of the constant zero, not all ones.  */
  1240.  
  1241.   if (unsignedp && GET_MODE_CLASS (mode) == MODE_INT
  1242.       && GET_MODE_BITSIZE (mode) == 2 * HOST_BITS_PER_WIDE_INT
  1243.       && GET_CODE (x) == CONST_INT && INTVAL (x) < 0)
  1244.     return immed_double_const (INTVAL (x), (HOST_WIDE_INT) 0, mode);
  1245.  
  1246.   /* We can do this with a gen_lowpart if both desired and current modes
  1247.      are integer, and this is either a constant integer, a register, or a
  1248.      non-volatile MEM.  Except for the constant case where MODE is no
  1249.      wider than HOST_BITS_PER_WIDE_INT, we must be narrowing the operand.  */
  1250.  
  1251.   if ((GET_CODE (x) == CONST_INT
  1252.        && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
  1253.       || (GET_MODE_CLASS (mode) == MODE_INT
  1254.       && GET_MODE_CLASS (oldmode) == MODE_INT
  1255.       && (GET_CODE (x) == CONST_DOUBLE
  1256.           || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (oldmode)
  1257.           && ((GET_CODE (x) == MEM && ! MEM_VOLATILE_P (x)
  1258.                && direct_load[(int) mode])
  1259.               || (GET_CODE (x) == REG
  1260.               && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
  1261.                             GET_MODE_BITSIZE (GET_MODE (x)))))))))
  1262.     {
  1263.       /* ?? If we don't know OLDMODE, we have to assume here that
  1264.      X does not need sign- or zero-extension.   This may not be
  1265.      the case, but it's the best we can do.  */
  1266.       if (GET_CODE (x) == CONST_INT && oldmode != VOIDmode
  1267.       && GET_MODE_SIZE (mode) > GET_MODE_SIZE (oldmode))
  1268.     {
  1269.       HOST_WIDE_INT val = INTVAL (x);
  1270.       int width = GET_MODE_BITSIZE (oldmode);
  1271.  
  1272.       /* We must sign or zero-extend in this case.  Start by
  1273.          zero-extending, then sign extend if we need to.  */
  1274.       val &= ((HOST_WIDE_INT) 1 << width) - 1;
  1275.       if (! unsignedp
  1276.           && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
  1277.         val |= (HOST_WIDE_INT) (-1) << width;
  1278.  
  1279.       return GEN_INT (val);
  1280.     }
  1281.  
  1282.       return gen_lowpart (mode, x);
  1283.     }
  1284.  
  1285.   temp = gen_reg_rtx (mode);
  1286.   convert_move (temp, x, unsignedp);
  1287.   return temp;
  1288. }
  1289.  
  1290. /* Generate several move instructions to copy LEN bytes
  1291.    from block FROM to block TO.  (These are MEM rtx's with BLKmode).
  1292.    The caller must pass FROM and TO
  1293.     through protect_from_queue before calling.
  1294.    ALIGN (in bytes) is maximum alignment we can assume.  */
  1295.  
  1296. static void
  1297. move_by_pieces (to, from, len, align)
  1298.      rtx to, from;
  1299.      int len, align;
  1300. {
  1301.   struct move_by_pieces data;
  1302.   rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
  1303.   int max_size = MOVE_MAX + 1;
  1304.  
  1305.   data.offset = 0;
  1306.   data.to_addr = to_addr;
  1307.   data.from_addr = from_addr;
  1308.   data.to = to;
  1309.   data.from = from;
  1310.   data.autinc_to
  1311.     = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
  1312.        || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
  1313.   data.autinc_from
  1314.     = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
  1315.        || GET_CODE (from_addr) == POST_INC
  1316.        || GET_CODE (from_addr) == POST_DEC);
  1317.  
  1318.   data.explicit_inc_from = 0;
  1319.   data.explicit_inc_to = 0;
  1320.   data.reverse
  1321.     = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
  1322.   if (data.reverse) data.offset = len;
  1323.   data.len = len;
  1324.  
  1325.   /* If copying requires more than two move insns,
  1326.      copy addresses to registers (to make displacements shorter)
  1327.      and use post-increment if available.  */
  1328.   if (!(data.autinc_from && data.autinc_to)
  1329.       && move_by_pieces_ninsns (len, align) > 2)
  1330.     {
  1331. #ifdef HAVE_PRE_DECREMENT
  1332.       if (data.reverse && ! data.autinc_from)
  1333.     {
  1334.       data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
  1335.       data.autinc_from = 1;
  1336.       data.explicit_inc_from = -1;
  1337.     }
  1338. #endif
  1339. #ifdef HAVE_POST_INCREMENT
  1340.       if (! data.autinc_from)
  1341.     {
  1342.       data.from_addr = copy_addr_to_reg (from_addr);
  1343.       data.autinc_from = 1;
  1344.       data.explicit_inc_from = 1;
  1345.     }
  1346. #endif
  1347.       if (!data.autinc_from && CONSTANT_P (from_addr))
  1348.     data.from_addr = copy_addr_to_reg (from_addr);
  1349. #ifdef HAVE_PRE_DECREMENT
  1350.       if (data.reverse && ! data.autinc_to)
  1351.     {
  1352.       data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
  1353.       data.autinc_to = 1;
  1354.       data.explicit_inc_to = -1;
  1355.     }
  1356. #endif
  1357. #ifdef HAVE_POST_INCREMENT
  1358.       if (! data.reverse && ! data.autinc_to)
  1359.     {
  1360.       data.to_addr = copy_addr_to_reg (to_addr);
  1361.       data.autinc_to = 1;
  1362.       data.explicit_inc_to = 1;
  1363.     }
  1364. #endif
  1365.       if (!data.autinc_to && CONSTANT_P (to_addr))
  1366.     data.to_addr = copy_addr_to_reg (to_addr);
  1367.     }
  1368.  
  1369.   if (! (STRICT_ALIGNMENT || SLOW_UNALIGNED_ACCESS)
  1370.       || align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1371.     align = MOVE_MAX;
  1372.  
  1373.   /* First move what we can in the largest integer mode, then go to
  1374.      successively smaller modes.  */
  1375.  
  1376.   while (max_size > 1)
  1377.     {
  1378.       enum machine_mode mode = VOIDmode, tmode;
  1379.       enum insn_code icode;
  1380.  
  1381.       for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  1382.        tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
  1383.     if (GET_MODE_SIZE (tmode) < max_size)
  1384.       mode = tmode;
  1385.  
  1386.       if (mode == VOIDmode)
  1387.     break;
  1388.  
  1389.       icode = mov_optab->handlers[(int) mode].insn_code;
  1390.       if (icode != CODE_FOR_nothing
  1391.       && align >= MIN (BIGGEST_ALIGNMENT / BITS_PER_UNIT,
  1392.                GET_MODE_SIZE (mode)))
  1393.     move_by_pieces_1 (GEN_FCN (icode), mode, &data);
  1394.  
  1395.       max_size = GET_MODE_SIZE (mode);
  1396.     }
  1397.  
  1398.   /* The code above should have handled everything.  */
  1399.   if (data.len != 0)
  1400.     abort ();
  1401. }
  1402.  
  1403. /* Return number of insns required to move L bytes by pieces.
  1404.    ALIGN (in bytes) is maximum alignment we can assume.  */
  1405.  
  1406. static int
  1407. move_by_pieces_ninsns (l, align)
  1408.      unsigned int l;
  1409.      int align;
  1410. {
  1411.   register int n_insns = 0;
  1412.   int max_size = MOVE_MAX + 1;
  1413.  
  1414.   if (! (STRICT_ALIGNMENT || SLOW_UNALIGNED_ACCESS)
  1415.       || align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1416.     align = MOVE_MAX;
  1417.  
  1418.   while (max_size > 1)
  1419.     {
  1420.       enum machine_mode mode = VOIDmode, tmode;
  1421.       enum insn_code icode;
  1422.  
  1423.       for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  1424.        tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
  1425.     if (GET_MODE_SIZE (tmode) < max_size)
  1426.       mode = tmode;
  1427.  
  1428.       if (mode == VOIDmode)
  1429.     break;
  1430.  
  1431.       icode = mov_optab->handlers[(int) mode].insn_code;
  1432.       if (icode != CODE_FOR_nothing
  1433.       && align >= MIN (BIGGEST_ALIGNMENT / BITS_PER_UNIT,
  1434.                GET_MODE_SIZE (mode)))
  1435.     n_insns += l / GET_MODE_SIZE (mode), l %= GET_MODE_SIZE (mode);
  1436.  
  1437.       max_size = GET_MODE_SIZE (mode);
  1438.     }
  1439.  
  1440.   return n_insns;
  1441. }
  1442.  
  1443. /* Subroutine of move_by_pieces.  Move as many bytes as appropriate
  1444.    with move instructions for mode MODE.  GENFUN is the gen_... function
  1445.    to make a move insn for that mode.  DATA has all the other info.  */
  1446.  
  1447. static void
  1448. move_by_pieces_1 (genfun, mode, data)
  1449.      rtx (*genfun) ();
  1450.      enum machine_mode mode;
  1451.      struct move_by_pieces *data;
  1452. {
  1453.   register int size = GET_MODE_SIZE (mode);
  1454.   register rtx to1, from1;
  1455.  
  1456.   while (data->len >= size)
  1457.     {
  1458.       if (data->reverse) data->offset -= size;
  1459.  
  1460.       to1 = (data->autinc_to
  1461.          ? gen_rtx (MEM, mode, data->to_addr)
  1462.          : change_address (data->to, mode,
  1463.                    plus_constant (data->to_addr, data->offset)));
  1464.       from1 =
  1465.     (data->autinc_from
  1466.      ? gen_rtx (MEM, mode, data->from_addr)
  1467.      : change_address (data->from, mode,
  1468.                plus_constant (data->from_addr, data->offset)));
  1469.  
  1470. #ifdef HAVE_PRE_DECREMENT
  1471.       if (data->explicit_inc_to < 0)
  1472.     emit_insn (gen_add2_insn (data->to_addr, GEN_INT (-size)));
  1473.       if (data->explicit_inc_from < 0)
  1474.     emit_insn (gen_add2_insn (data->from_addr, GEN_INT (-size)));
  1475. #endif
  1476.  
  1477.       emit_insn ((*genfun) (to1, from1));
  1478. #ifdef HAVE_POST_INCREMENT
  1479.       if (data->explicit_inc_to > 0)
  1480.     emit_insn (gen_add2_insn (data->to_addr, GEN_INT (size)));
  1481.       if (data->explicit_inc_from > 0)
  1482.     emit_insn (gen_add2_insn (data->from_addr, GEN_INT (size)));
  1483. #endif
  1484.  
  1485.       if (! data->reverse) data->offset += size;
  1486.  
  1487.       data->len -= size;
  1488.     }
  1489. }
  1490.  
  1491. /* Emit code to move a block Y to a block X.
  1492.    This may be done with string-move instructions,
  1493.    with multiple scalar move instructions, or with a library call.
  1494.  
  1495.    Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
  1496.    with mode BLKmode.
  1497.    SIZE is an rtx that says how long they are.
  1498.    ALIGN is the maximum alignment we can assume they have,
  1499.    measured in bytes.  */
  1500.  
  1501. void
  1502. emit_block_move (x, y, size, align)
  1503.      rtx x, y;
  1504.      rtx size;
  1505.      int align;
  1506. {
  1507.   if (GET_MODE (x) != BLKmode)
  1508.     abort ();
  1509.  
  1510.   if (GET_MODE (y) != BLKmode)
  1511.     abort ();
  1512.  
  1513.   x = protect_from_queue (x, 1);
  1514.   y = protect_from_queue (y, 0);
  1515.   size = protect_from_queue (size, 0);
  1516.  
  1517.   if (GET_CODE (x) != MEM)
  1518.     abort ();
  1519.   if (GET_CODE (y) != MEM)
  1520.     abort ();
  1521.   if (size == 0)
  1522.     abort ();
  1523.  
  1524.   if (GET_CODE (size) == CONST_INT
  1525.       && (move_by_pieces_ninsns (INTVAL (size), align) < MOVE_RATIO))
  1526.     move_by_pieces (x, y, INTVAL (size), align);
  1527.   else
  1528.     {
  1529.       /* Try the most limited insn first, because there's no point
  1530.      including more than one in the machine description unless
  1531.      the more limited one has some advantage.  */
  1532.  
  1533.       rtx opalign = GEN_INT (align);
  1534.       enum machine_mode mode;
  1535.  
  1536.       for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
  1537.        mode = GET_MODE_WIDER_MODE (mode))
  1538.     {
  1539.       enum insn_code code = movstr_optab[(int) mode];
  1540.  
  1541.       if (code != CODE_FOR_nothing
  1542.           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
  1543.          here because if SIZE is less than the mode mask, as it is
  1544.          returned by the macro, it will definitely be less than the
  1545.          actual mode mask.  */
  1546.           && (unsigned HOST_WIDE_INT) INTVAL (size) <= GET_MODE_MASK (mode)
  1547.           && (insn_operand_predicate[(int) code][0] == 0
  1548.           || (*insn_operand_predicate[(int) code][0]) (x, BLKmode))
  1549.           && (insn_operand_predicate[(int) code][1] == 0
  1550.           || (*insn_operand_predicate[(int) code][1]) (y, BLKmode))
  1551.           && (insn_operand_predicate[(int) code][3] == 0
  1552.           || (*insn_operand_predicate[(int) code][3]) (opalign,
  1553.                                    VOIDmode)))
  1554.         {
  1555.           rtx op2;
  1556.           rtx last = get_last_insn ();
  1557.           rtx pat;
  1558.  
  1559.           op2 = convert_to_mode (mode, size, 1);
  1560.           if (insn_operand_predicate[(int) code][2] != 0
  1561.           && ! (*insn_operand_predicate[(int) code][2]) (op2, mode))
  1562.         op2 = copy_to_mode_reg (mode, op2);
  1563.  
  1564.           pat = GEN_FCN ((int) code) (x, y, op2, opalign);
  1565.           if (pat)
  1566.         {
  1567.           emit_insn (pat);
  1568.           return;
  1569.         }
  1570.           else
  1571.         delete_insns_since (last);
  1572.         }
  1573.     }
  1574.  
  1575. #ifdef TARGET_MEM_FUNCTIONS
  1576.       emit_library_call (memcpy_libfunc, 0,
  1577.              VOIDmode, 3, XEXP (x, 0), Pmode,
  1578.              XEXP (y, 0), Pmode,
  1579.              convert_to_mode (TYPE_MODE (sizetype), size,
  1580.                       TREE_UNSIGNED (sizetype)),
  1581.              TYPE_MODE (sizetype));
  1582. #else
  1583.       emit_library_call (bcopy_libfunc, 0,
  1584.              VOIDmode, 3, XEXP (y, 0), Pmode,
  1585.              XEXP (x, 0), Pmode,
  1586.              convert_to_mode (TYPE_MODE (sizetype), size,
  1587.                       TREE_UNSIGNED (sizetype)),
  1588.              TYPE_MODE (sizetype));
  1589. #endif
  1590.     }
  1591. }
  1592.  
  1593. /* Copy all or part of a value X into registers starting at REGNO.
  1594.    The number of registers to be filled is NREGS.  */
  1595.  
  1596. void
  1597. move_block_to_reg (regno, x, nregs, mode)
  1598.      int regno;
  1599.      rtx x;
  1600.      int nregs;
  1601.      enum machine_mode mode;
  1602. {
  1603.   int i;
  1604.   rtx pat, last;
  1605.  
  1606.   if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  1607.     x = validize_mem (force_const_mem (mode, x));
  1608.  
  1609.   /* See if the machine can do this with a load multiple insn.  */
  1610. #ifdef HAVE_load_multiple
  1611.   if (HAVE_load_multiple)
  1612.     {
  1613.       last = get_last_insn ();
  1614.       pat = gen_load_multiple (gen_rtx (REG, word_mode, regno), x,
  1615.                    GEN_INT (nregs));
  1616.       if (pat)
  1617.     {
  1618.       emit_insn (pat);
  1619.       return;
  1620.     }
  1621.       else
  1622.     delete_insns_since (last);
  1623.     }
  1624. #endif
  1625.  
  1626.   for (i = 0; i < nregs; i++)
  1627.     emit_move_insn (gen_rtx (REG, word_mode, regno + i),
  1628.             operand_subword_force (x, i, mode));
  1629. }
  1630.  
  1631. /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
  1632.    The number of registers to be filled is NREGS.  SIZE indicates the number
  1633.    of bytes in the object X.  */
  1634.  
  1635.  
  1636. void
  1637. move_block_from_reg (regno, x, nregs, size)
  1638.      int regno;
  1639.      rtx x;
  1640.      int nregs;
  1641.      int size;
  1642. {
  1643.   int i;
  1644.   rtx pat, last;
  1645.  
  1646.   /* Blocks smaller than a word on a BYTES_BIG_ENDIAN machine must be aligned
  1647.      to the left before storing to memory.  */
  1648.   if (size < UNITS_PER_WORD && BYTES_BIG_ENDIAN)
  1649.     {
  1650.       rtx tem = operand_subword (x, 0, 1, BLKmode);
  1651.       rtx shift;
  1652.  
  1653.       if (tem == 0)
  1654.     abort ();
  1655.  
  1656.       shift = expand_shift (LSHIFT_EXPR, word_mode,
  1657.                 gen_rtx (REG, word_mode, regno),
  1658.                 build_int_2 ((UNITS_PER_WORD - size)
  1659.                      * BITS_PER_UNIT, 0), NULL_RTX, 0);
  1660.       emit_move_insn (tem, shift);
  1661.       return;
  1662.     }
  1663.  
  1664.   /* See if the machine can do this with a store multiple insn.  */
  1665. #ifdef HAVE_store_multiple
  1666.   if (HAVE_store_multiple)
  1667.     {
  1668.       last = get_last_insn ();
  1669.       pat = gen_store_multiple (x, gen_rtx (REG, word_mode, regno),
  1670.                 GEN_INT (nregs));
  1671.       if (pat)
  1672.     {
  1673.       emit_insn (pat);
  1674.       return;
  1675.     }
  1676.       else
  1677.     delete_insns_since (last);
  1678.     }
  1679. #endif
  1680.  
  1681.   for (i = 0; i < nregs; i++)
  1682.     {
  1683.       rtx tem = operand_subword (x, i, 1, BLKmode);
  1684.  
  1685.       if (tem == 0)
  1686.     abort ();
  1687.  
  1688.       emit_move_insn (tem, gen_rtx (REG, word_mode, regno + i));
  1689.     }
  1690. }
  1691.  
  1692. /* Add a USE expression for REG to the (possibly empty) list pointed
  1693.    to by CALL_FUSAGE.  REG must denote a hard register.  */
  1694.  
  1695. void
  1696. use_reg (call_fusage, reg)
  1697.      rtx *call_fusage, reg;
  1698. {
  1699.   if (GET_CODE (reg) != REG
  1700.       || REGNO (reg) >= FIRST_PSEUDO_REGISTER)
  1701.     abort();
  1702.  
  1703.   *call_fusage
  1704.     = gen_rtx (EXPR_LIST, VOIDmode,
  1705.            gen_rtx (USE, VOIDmode, reg), *call_fusage);
  1706. }
  1707.  
  1708. /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs,
  1709.    starting at REGNO.  All of these registers must be hard registers.  */
  1710.  
  1711. void
  1712. use_regs (call_fusage, regno, nregs)
  1713.      rtx *call_fusage;
  1714.      int regno;
  1715.      int nregs;
  1716. {
  1717.   int i;
  1718.  
  1719.   if (regno + nregs > FIRST_PSEUDO_REGISTER)
  1720.     abort ();
  1721.  
  1722.   for (i = 0; i < nregs; i++)
  1723.     use_reg (call_fusage, gen_rtx (REG, reg_raw_mode[regno + i], regno + i));
  1724. }
  1725.  
  1726. /* Write zeros through the storage of OBJECT.
  1727.    If OBJECT has BLKmode, SIZE is its length in bytes.  */
  1728.  
  1729. void
  1730. clear_storage (object, size)
  1731.      rtx object;
  1732.      int size;
  1733. {
  1734.   if (GET_MODE (object) == BLKmode)
  1735.     {
  1736. #ifdef TARGET_MEM_FUNCTIONS
  1737.       emit_library_call (memset_libfunc, 0,
  1738.              VOIDmode, 3,
  1739.              XEXP (object, 0), Pmode, const0_rtx, Pmode,
  1740.              GEN_INT (size), Pmode);
  1741. #else
  1742.       emit_library_call (bzero_libfunc, 0,
  1743.              VOIDmode, 2,
  1744.              XEXP (object, 0), Pmode,
  1745.              GEN_INT (size), Pmode);
  1746. #endif
  1747.     }
  1748.   else
  1749.     emit_move_insn (object, const0_rtx);
  1750. }
  1751.  
  1752. /* Generate code to copy Y into X.
  1753.    Both Y and X must have the same mode, except that
  1754.    Y can be a constant with VOIDmode.
  1755.    This mode cannot be BLKmode; use emit_block_move for that.
  1756.  
  1757.    Return the last instruction emitted.  */
  1758.  
  1759. rtx
  1760. emit_move_insn (x, y)
  1761.      rtx x, y;
  1762. {
  1763.   enum machine_mode mode = GET_MODE (x);
  1764.  
  1765.   x = protect_from_queue (x, 1);
  1766.   y = protect_from_queue (y, 0);
  1767.  
  1768.   if (mode == BLKmode || (GET_MODE (y) != mode && GET_MODE (y) != VOIDmode))
  1769.     abort ();
  1770.  
  1771.   if (CONSTANT_P (y) && ! LEGITIMATE_CONSTANT_P (y))
  1772.     y = force_const_mem (mode, y);
  1773.  
  1774.   /* If X or Y are memory references, verify that their addresses are valid
  1775.      for the machine.  */
  1776.   if (GET_CODE (x) == MEM
  1777.       && ((! memory_address_p (GET_MODE (x), XEXP (x, 0))
  1778.        && ! push_operand (x, GET_MODE (x)))
  1779.       || (flag_force_addr
  1780.           && CONSTANT_ADDRESS_P (XEXP (x, 0)))))
  1781.     x = change_address (x, VOIDmode, XEXP (x, 0));
  1782.  
  1783.   if (GET_CODE (y) == MEM
  1784.       && (! memory_address_p (GET_MODE (y), XEXP (y, 0))
  1785.       || (flag_force_addr
  1786.           && CONSTANT_ADDRESS_P (XEXP (y, 0)))))
  1787.     y = change_address (y, VOIDmode, XEXP (y, 0));
  1788.  
  1789.   if (mode == BLKmode)
  1790.     abort ();
  1791.  
  1792.   return emit_move_insn_1 (x, y);
  1793. }
  1794.  
  1795. /* Low level part of emit_move_insn.
  1796.    Called just like emit_move_insn, but assumes X and Y
  1797.    are basically valid.  */
  1798.  
  1799. rtx
  1800. emit_move_insn_1 (x, y)
  1801.      rtx x, y;
  1802. {
  1803.   enum machine_mode mode = GET_MODE (x);
  1804.   enum machine_mode submode;
  1805.   enum mode_class class = GET_MODE_CLASS (mode);
  1806.   int i;
  1807.  
  1808.   if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  1809.     return
  1810.       emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
  1811.  
  1812.   /* Expand complex moves by moving real part and imag part, if possible.  */
  1813.   else if ((class == MODE_COMPLEX_FLOAT || class == MODE_COMPLEX_INT)
  1814.        && BLKmode != (submode = mode_for_size ((GET_MODE_UNIT_SIZE (mode)
  1815.                             * BITS_PER_UNIT),
  1816.                            (class == MODE_COMPLEX_INT
  1817.                             ? MODE_INT : MODE_FLOAT),
  1818.                            0))
  1819.        && (mov_optab->handlers[(int) submode].insn_code
  1820.            != CODE_FOR_nothing))
  1821.     {
  1822.       /* Don't split destination if it is a stack push.  */
  1823.       int stack = push_operand (x, GET_MODE (x));
  1824.       rtx insns;
  1825.  
  1826.       start_sequence ();
  1827.  
  1828.       /* If this is a stack, push the highpart first, so it
  1829.      will be in the argument order.
  1830.  
  1831.      In that case, change_address is used only to convert
  1832.      the mode, not to change the address.  */
  1833.       if (stack)
  1834.     {
  1835.       /* Note that the real part always precedes the imag part in memory
  1836.          regardless of machine's endianness.  */
  1837. #ifdef STACK_GROWS_DOWNWARD
  1838.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1839.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1840.               gen_imagpart (submode, y)));
  1841.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1842.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1843.               gen_realpart (submode, y)));
  1844. #else
  1845.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1846.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1847.               gen_realpart (submode, y)));
  1848.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1849.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1850.               gen_imagpart (submode, y)));
  1851. #endif
  1852.     }
  1853.       else
  1854.     {
  1855.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1856.              (gen_realpart (submode, x), gen_realpart (submode, y)));
  1857.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1858.              (gen_imagpart (submode, x), gen_imagpart (submode, y)));
  1859.     }
  1860.  
  1861.       insns = get_insns ();
  1862.       end_sequence ();
  1863.  
  1864.       /* If X is a CONCAT, we got insns like RD = RS, ID = IS,
  1865.      each with a separate pseudo as destination.
  1866.      It's not correct for flow to treat them as a unit.  */
  1867.       if (GET_CODE (x) != CONCAT)
  1868.     emit_no_conflict_block (insns, x, y, NULL_RTX, NULL_RTX);
  1869.       else
  1870.     emit_insns (insns);
  1871.  
  1872.       return get_last_insn ();
  1873.     }
  1874.  
  1875.   /* This will handle any multi-word mode that lacks a move_insn pattern.
  1876.      However, you will get better code if you define such patterns,
  1877.      even if they must turn into multiple assembler instructions.  */
  1878.   else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
  1879.     {
  1880.       rtx last_insn = 0;
  1881.       rtx insns;
  1882.       
  1883.       start_sequence ();
  1884.  
  1885.       for (i = 0;
  1886.        i < (GET_MODE_SIZE (mode)  + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
  1887.        i++)
  1888.     {
  1889.       rtx xpart = operand_subword (x, i, 1, mode);
  1890.       rtx ypart = operand_subword (y, i, 1, mode);
  1891.  
  1892.       /* If we can't get a part of Y, put Y into memory if it is a
  1893.          constant.  Otherwise, force it into a register.  If we still
  1894.          can't get a part of Y, abort.  */
  1895.       if (ypart == 0 && CONSTANT_P (y))
  1896.         {
  1897.           y = force_const_mem (mode, y);
  1898.           ypart = operand_subword (y, i, 1, mode);
  1899.         }
  1900.       else if (ypart == 0)
  1901.         ypart = operand_subword_force (y, i, mode);
  1902.  
  1903.       if (xpart == 0 || ypart == 0)
  1904.         abort ();
  1905.  
  1906.       last_insn = emit_move_insn (xpart, ypart);
  1907.     }
  1908.  
  1909.       insns = get_insns ();
  1910.       end_sequence ();
  1911.       emit_no_conflict_block (insns, x, y, NULL_RTX, NULL_RTX);
  1912.  
  1913.       return last_insn;
  1914.     }
  1915.   else
  1916.     abort ();
  1917. }
  1918.  
  1919. /* Pushing data onto the stack.  */
  1920.  
  1921. /* Push a block of length SIZE (perhaps variable)
  1922.    and return an rtx to address the beginning of the block.
  1923.    Note that it is not possible for the value returned to be a QUEUED.
  1924.    The value may be virtual_outgoing_args_rtx.
  1925.  
  1926.    EXTRA is the number of bytes of padding to push in addition to SIZE.
  1927.    BELOW nonzero means this padding comes at low addresses;
  1928.    otherwise, the padding comes at high addresses.  */
  1929.  
  1930. rtx
  1931. push_block (size, extra, below)
  1932.      rtx size;
  1933.      int extra, below;
  1934. {
  1935.   register rtx temp;
  1936.   if (CONSTANT_P (size))
  1937.     anti_adjust_stack (plus_constant (size, extra));
  1938.   else if (GET_CODE (size) == REG && extra == 0)
  1939.     anti_adjust_stack (size);
  1940.   else
  1941.     {
  1942.       rtx temp = copy_to_mode_reg (Pmode, size);
  1943.       if (extra != 0)
  1944.     temp = expand_binop (Pmode, add_optab, temp, GEN_INT (extra),
  1945.                  temp, 0, OPTAB_LIB_WIDEN);
  1946.       anti_adjust_stack (temp);
  1947.     }
  1948.  
  1949. #ifdef STACK_GROWS_DOWNWARD
  1950.   temp = virtual_outgoing_args_rtx;
  1951.   if (extra != 0 && below)
  1952.     temp = plus_constant (temp, extra);
  1953. #else
  1954.   if (GET_CODE (size) == CONST_INT)
  1955.     temp = plus_constant (virtual_outgoing_args_rtx,
  1956.               - INTVAL (size) - (below ? 0 : extra));
  1957.   else if (extra != 0 && !below)
  1958.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  1959.             negate_rtx (Pmode, plus_constant (size, extra)));
  1960.   else
  1961.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  1962.             negate_rtx (Pmode, size));
  1963. #endif
  1964.  
  1965.   return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT), temp);
  1966. }
  1967.  
  1968. rtx
  1969. gen_push_operand ()
  1970. {
  1971.   return gen_rtx (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
  1972. }
  1973.  
  1974. /* Generate code to push X onto the stack, assuming it has mode MODE and
  1975.    type TYPE.
  1976.    MODE is redundant except when X is a CONST_INT (since they don't
  1977.    carry mode info).
  1978.    SIZE is an rtx for the size of data to be copied (in bytes),
  1979.    needed only if X is BLKmode.
  1980.  
  1981.    ALIGN (in bytes) is maximum alignment we can assume.
  1982.  
  1983.    If PARTIAL and REG are both nonzero, then copy that many of the first
  1984.    words of X into registers starting with REG, and push the rest of X.
  1985.    The amount of space pushed is decreased by PARTIAL words,
  1986.    rounded *down* to a multiple of PARM_BOUNDARY.
  1987.    REG must be a hard register in this case.
  1988.    If REG is zero but PARTIAL is not, take any all others actions for an
  1989.    argument partially in registers, but do not actually load any
  1990.    registers.
  1991.  
  1992.    EXTRA is the amount in bytes of extra space to leave next to this arg.
  1993.    This is ignored if an argument block has already been allocated.
  1994.  
  1995.    On a machine that lacks real push insns, ARGS_ADDR is the address of
  1996.    the bottom of the argument block for this call.  We use indexing off there
  1997.    to store the arg.  On machines with push insns, ARGS_ADDR is 0 when a
  1998.    argument block has not been preallocated.
  1999.  
  2000.    ARGS_SO_FAR is the size of args previously pushed for this call.  */
  2001.  
  2002. void
  2003. emit_push_insn (x, mode, type, size, align, partial, reg, extra,
  2004.         args_addr, args_so_far)
  2005.      register rtx x;
  2006.      enum machine_mode mode;
  2007.      tree type;
  2008.      rtx size;
  2009.      int align;
  2010.      int partial;
  2011.      rtx reg;
  2012.      int extra;
  2013.      rtx args_addr;
  2014.      rtx args_so_far;
  2015. {
  2016.   rtx xinner;
  2017.   enum direction stack_direction
  2018. #ifdef STACK_GROWS_DOWNWARD
  2019.     = downward;
  2020. #else
  2021.     = upward;
  2022. #endif
  2023.  
  2024.   /* Decide where to pad the argument: `downward' for below,
  2025.      `upward' for above, or `none' for don't pad it.
  2026.      Default is below for small data on big-endian machines; else above.  */
  2027.   enum direction where_pad = FUNCTION_ARG_PADDING (mode, type);
  2028.  
  2029.   /* Invert direction if stack is post-update.  */
  2030.   if (STACK_PUSH_CODE == POST_INC || STACK_PUSH_CODE == POST_DEC)
  2031.     if (where_pad != none)
  2032.       where_pad = (where_pad == downward ? upward : downward);
  2033.  
  2034.   xinner = x = protect_from_queue (x, 0);
  2035.  
  2036.   if (mode == BLKmode)
  2037.     {
  2038.       /* Copy a block into the stack, entirely or partially.  */
  2039.  
  2040.       register rtx temp;
  2041.       int used = partial * UNITS_PER_WORD;
  2042.       int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
  2043.       int skip;
  2044.       
  2045.       if (size == 0)
  2046.     abort ();
  2047.  
  2048.       used -= offset;
  2049.  
  2050.       /* USED is now the # of bytes we need not copy to the stack
  2051.      because registers will take care of them.  */
  2052.  
  2053.       if (partial != 0)
  2054.     xinner = change_address (xinner, BLKmode,
  2055.                  plus_constant (XEXP (xinner, 0), used));
  2056.  
  2057.       /* If the partial register-part of the arg counts in its stack size,
  2058.      skip the part of stack space corresponding to the registers.
  2059.      Otherwise, start copying to the beginning of the stack space,
  2060.      by setting SKIP to 0.  */
  2061. #ifndef REG_PARM_STACK_SPACE
  2062.       skip = 0;
  2063. #else
  2064.       skip = used;
  2065. #endif
  2066.  
  2067. #ifdef PUSH_ROUNDING
  2068.       /* Do it with several push insns if that doesn't take lots of insns
  2069.      and if there is no difficulty with push insns that skip bytes
  2070.      on the stack for alignment purposes.  */
  2071.       if (args_addr == 0
  2072.       && GET_CODE (size) == CONST_INT
  2073.       && skip == 0
  2074.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
  2075.           < MOVE_RATIO)
  2076.       /* Here we avoid the case of a structure whose weak alignment
  2077.          forces many pushes of a small amount of data,
  2078.          and such small pushes do rounding that causes trouble.  */
  2079.       && ((! STRICT_ALIGNMENT && ! SLOW_UNALIGNED_ACCESS)
  2080.           || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT
  2081.           || PUSH_ROUNDING (align) == align)
  2082.       && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
  2083.     {
  2084.       /* Push padding now if padding above and stack grows down,
  2085.          or if padding below and stack grows up.
  2086.          But if space already allocated, this has already been done.  */
  2087.       if (extra && args_addr == 0
  2088.           && where_pad != none && where_pad != stack_direction)
  2089.         anti_adjust_stack (GEN_INT (extra));
  2090.  
  2091.       move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
  2092.               INTVAL (size) - used, align);
  2093.     }
  2094.       else
  2095. #endif /* PUSH_ROUNDING */
  2096.     {
  2097.       /* Otherwise make space on the stack and copy the data
  2098.          to the address of that space.  */
  2099.  
  2100.       /* Deduct words put into registers from the size we must copy.  */
  2101.       if (partial != 0)
  2102.         {
  2103.           if (GET_CODE (size) == CONST_INT)
  2104.         size = GEN_INT (INTVAL (size) - used);
  2105.           else
  2106.         size = expand_binop (GET_MODE (size), sub_optab, size,
  2107.                      GEN_INT (used), NULL_RTX, 0,
  2108.                      OPTAB_LIB_WIDEN);
  2109.         }
  2110.  
  2111.       /* Get the address of the stack space.
  2112.          In this case, we do not deal with EXTRA separately.
  2113.          A single stack adjust will do.  */
  2114.       if (! args_addr)
  2115.         {
  2116.           temp = push_block (size, extra, where_pad == downward);
  2117.           extra = 0;
  2118.         }
  2119.       else if (GET_CODE (args_so_far) == CONST_INT)
  2120.         temp = memory_address (BLKmode,
  2121.                    plus_constant (args_addr,
  2122.                           skip + INTVAL (args_so_far)));
  2123.       else
  2124.         temp = memory_address (BLKmode,
  2125.                    plus_constant (gen_rtx (PLUS, Pmode,
  2126.                                args_addr, args_so_far),
  2127.                           skip));
  2128.  
  2129.       /* TEMP is the address of the block.  Copy the data there.  */
  2130.       if (GET_CODE (size) == CONST_INT
  2131.           && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  2132.           < MOVE_RATIO))
  2133.         {
  2134.           move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
  2135.                   INTVAL (size), align);
  2136.           goto ret;
  2137.         }
  2138.       /* Try the most limited insn first, because there's no point
  2139.          including more than one in the machine description unless
  2140.          the more limited one has some advantage.  */
  2141. #ifdef HAVE_movstrqi
  2142.       if (HAVE_movstrqi
  2143.           && GET_CODE (size) == CONST_INT
  2144.           && ((unsigned) INTVAL (size)
  2145.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  2146.         {
  2147.           rtx pat = gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
  2148.                       xinner, size, GEN_INT (align));
  2149.           if (pat != 0)
  2150.         {
  2151.           emit_insn (pat);
  2152.           goto ret;
  2153.         }
  2154.         }
  2155. #endif
  2156. #ifdef HAVE_movstrhi
  2157.       if (HAVE_movstrhi
  2158.           && GET_CODE (size) == CONST_INT
  2159.           && ((unsigned) INTVAL (size)
  2160.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  2161.         {
  2162.           rtx pat = gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
  2163.                       xinner, size, GEN_INT (align));
  2164.           if (pat != 0)
  2165.         {
  2166.           emit_insn (pat);
  2167.           goto ret;
  2168.         }
  2169.         }
  2170. #endif
  2171. #ifdef HAVE_movstrsi
  2172.       if (HAVE_movstrsi)
  2173.         {
  2174.           rtx pat = gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
  2175.                       xinner, size, GEN_INT (align));
  2176.           if (pat != 0)
  2177.         {
  2178.           emit_insn (pat);
  2179.           goto ret;
  2180.         }
  2181.         }
  2182. #endif
  2183. #ifdef HAVE_movstrdi
  2184.       if (HAVE_movstrdi)
  2185.         {
  2186.           rtx pat = gen_movstrdi (gen_rtx (MEM, BLKmode, temp),
  2187.                       xinner, size, GEN_INT (align));
  2188.           if (pat != 0)
  2189.         {
  2190.           emit_insn (pat);
  2191.           goto ret;
  2192.         }
  2193.         }
  2194. #endif
  2195.  
  2196. #ifndef ACCUMULATE_OUTGOING_ARGS
  2197.       /* If the source is referenced relative to the stack pointer,
  2198.          copy it to another register to stabilize it.  We do not need
  2199.          to do this if we know that we won't be changing sp.  */
  2200.  
  2201.       if (reg_mentioned_p (virtual_stack_dynamic_rtx, temp)
  2202.           || reg_mentioned_p (virtual_outgoing_args_rtx, temp))
  2203.         temp = copy_to_reg (temp);
  2204. #endif
  2205.  
  2206.       /* Make inhibit_defer_pop nonzero around the library call
  2207.          to force it to pop the bcopy-arguments right away.  */
  2208.       NO_DEFER_POP;
  2209. #ifdef TARGET_MEM_FUNCTIONS
  2210.       emit_library_call (memcpy_libfunc, 0,
  2211.                  VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
  2212.                  convert_to_mode (TYPE_MODE (sizetype),
  2213.                           size, TREE_UNSIGNED (sizetype)),
  2214.                  TYPE_MODE (sizetype));
  2215. #else
  2216.       emit_library_call (bcopy_libfunc, 0,
  2217.                  VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
  2218.                  convert_to_mode (TYPE_MODE (sizetype),
  2219.                           size, TREE_UNSIGNED (sizetype)),
  2220.                  TYPE_MODE (sizetype));
  2221. #endif
  2222.       OK_DEFER_POP;
  2223.     }
  2224.     }
  2225.   else if (partial > 0)
  2226.     {
  2227.       /* Scalar partly in registers.  */
  2228.  
  2229.       int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  2230.       int i;
  2231.       int not_stack;
  2232.       /* # words of start of argument
  2233.      that we must make space for but need not store.  */
  2234.       int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
  2235.       int args_offset = INTVAL (args_so_far);
  2236.       int skip;
  2237.  
  2238.       /* Push padding now if padding above and stack grows down,
  2239.      or if padding below and stack grows up.
  2240.      But if space already allocated, this has already been done.  */
  2241.       if (extra && args_addr == 0
  2242.       && where_pad != none && where_pad != stack_direction)
  2243.     anti_adjust_stack (GEN_INT (extra));
  2244.  
  2245.       /* If we make space by pushing it, we might as well push
  2246.      the real data.  Otherwise, we can leave OFFSET nonzero
  2247.      and leave the space uninitialized.  */
  2248.       if (args_addr == 0)
  2249.     offset = 0;
  2250.  
  2251.       /* Now NOT_STACK gets the number of words that we don't need to
  2252.      allocate on the stack.  */
  2253.       not_stack = partial - offset;
  2254.  
  2255.       /* If the partial register-part of the arg counts in its stack size,
  2256.      skip the part of stack space corresponding to the registers.
  2257.      Otherwise, start copying to the beginning of the stack space,
  2258.      by setting SKIP to 0.  */
  2259. #ifndef REG_PARM_STACK_SPACE
  2260.       skip = 0;
  2261. #else
  2262.       skip = not_stack;
  2263. #endif
  2264.  
  2265.       if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  2266.     x = validize_mem (force_const_mem (mode, x));
  2267.  
  2268.       /* If X is a hard register in a non-integer mode, copy it into a pseudo;
  2269.      SUBREGs of such registers are not allowed.  */
  2270.       if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER
  2271.        && GET_MODE_CLASS (GET_MODE (x)) != MODE_INT))
  2272.     x = copy_to_reg (x);
  2273.  
  2274.       /* Loop over all the words allocated on the stack for this arg.  */
  2275.       /* We can do it by words, because any scalar bigger than a word
  2276.      has a size a multiple of a word.  */
  2277. #ifndef PUSH_ARGS_REVERSED
  2278.       for (i = not_stack; i < size; i++)
  2279. #else
  2280.       for (i = size - 1; i >= not_stack; i--)
  2281. #endif
  2282.     if (i >= not_stack + offset)
  2283.       emit_push_insn (operand_subword_force (x, i, mode),
  2284.               word_mode, NULL_TREE, NULL_RTX, align, 0, NULL_RTX,
  2285.               0, args_addr,
  2286.               GEN_INT (args_offset + ((i - not_stack + skip)
  2287.                           * UNITS_PER_WORD)));
  2288.     }
  2289.   else
  2290.     {
  2291.       rtx addr;
  2292.  
  2293.       /* Push padding now if padding above and stack grows down,
  2294.      or if padding below and stack grows up.
  2295.      But if space already allocated, this has already been done.  */
  2296.       if (extra && args_addr == 0
  2297.       && where_pad != none && where_pad != stack_direction)
  2298.     anti_adjust_stack (GEN_INT (extra));
  2299.  
  2300. #ifdef PUSH_ROUNDING
  2301.       if (args_addr == 0)
  2302.     addr = gen_push_operand ();
  2303.       else
  2304. #endif
  2305.     if (GET_CODE (args_so_far) == CONST_INT)
  2306.       addr
  2307.         = memory_address (mode,
  2308.                   plus_constant (args_addr, INTVAL (args_so_far)));
  2309.       else
  2310.     addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
  2311.                           args_so_far));
  2312.  
  2313.       emit_move_insn (gen_rtx (MEM, mode, addr), x);
  2314.     }
  2315.  
  2316.  ret:
  2317.   /* If part should go in registers, copy that part
  2318.      into the appropriate registers.  Do this now, at the end,
  2319.      since mem-to-mem copies above may do function calls.  */
  2320.   if (partial > 0 && reg != 0)
  2321.     move_block_to_reg (REGNO (reg), x, partial, mode);
  2322.  
  2323.   if (extra && args_addr == 0 && where_pad == stack_direction)
  2324.     anti_adjust_stack (GEN_INT (extra));
  2325. }
  2326.  
  2327. /* Expand an assignment that stores the value of FROM into TO.
  2328.    If WANT_VALUE is nonzero, return an rtx for the value of TO.
  2329.    (This may contain a QUEUED rtx;
  2330.    if the value is constant, this rtx is a constant.)
  2331.    Otherwise, the returned value is NULL_RTX.
  2332.  
  2333.    SUGGEST_REG is no longer actually used.
  2334.    It used to mean, copy the value through a register
  2335.    and return that register, if that is possible.
  2336.    We now use WANT_VALUE to decide whether to do this.  */
  2337.  
  2338. rtx
  2339. expand_assignment (to, from, want_value, suggest_reg)
  2340.      tree to, from;
  2341.      int want_value;
  2342.      int suggest_reg;
  2343. {
  2344.   register rtx to_rtx = 0;
  2345.   rtx result;
  2346.  
  2347.   /* Don't crash if the lhs of the assignment was erroneous.  */
  2348.  
  2349.   if (TREE_CODE (to) == ERROR_MARK)
  2350.     {
  2351.       result = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2352.       return want_value ? result : NULL_RTX;
  2353.     }
  2354.  
  2355.   if (output_bytecode)
  2356.     {
  2357.       tree dest_innermost;
  2358.  
  2359.       bc_expand_expr (from);
  2360.       bc_emit_instruction (duplicate);
  2361.  
  2362.       dest_innermost = bc_expand_address (to);
  2363.  
  2364.       /* Can't deduce from TYPE that we're dealing with a bitfield, so
  2365.      take care of it here. */
  2366.  
  2367.       bc_store_memory (TREE_TYPE (to), dest_innermost);
  2368.       return NULL;
  2369.     }
  2370.  
  2371.   /* Assignment of a structure component needs special treatment
  2372.      if the structure component's rtx is not simply a MEM.
  2373.      Assignment of an array element at a constant index, and assignment of
  2374.      an array element in an unaligned packed structure field, has the same
  2375.      problem.  */
  2376.  
  2377.   if (TREE_CODE (to) == COMPONENT_REF
  2378.       || TREE_CODE (to) == BIT_FIELD_REF
  2379.       || (TREE_CODE (to) == ARRAY_REF
  2380.       && ((TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
  2381.            && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST)
  2382.           || (STRICT_ALIGNMENT && get_inner_unaligned_p (to)))))
  2383.     {
  2384.       enum machine_mode mode1;
  2385.       int bitsize;
  2386.       int bitpos;
  2387.       tree offset;
  2388.       int unsignedp;
  2389.       int volatilep = 0;
  2390.       tree tem;
  2391.       int alignment;
  2392.  
  2393.       push_temp_slots ();
  2394.       tem = get_inner_reference (to, &bitsize, &bitpos, &offset,
  2395.                       &mode1, &unsignedp, &volatilep);
  2396.  
  2397.       /* If we are going to use store_bit_field and extract_bit_field,
  2398.      make sure to_rtx will be safe for multiple use.  */
  2399.  
  2400.       if (mode1 == VOIDmode && want_value)
  2401.     tem = stabilize_reference (tem);
  2402.  
  2403.       alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
  2404.       to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, 0);
  2405.       if (offset != 0)
  2406.     {
  2407.       rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  2408.  
  2409.       if (GET_CODE (to_rtx) != MEM)
  2410.         abort ();
  2411.       to_rtx = change_address (to_rtx, VOIDmode,
  2412.                    gen_rtx (PLUS, Pmode, XEXP (to_rtx, 0),
  2413.                         force_reg (Pmode, offset_rtx)));
  2414.       /* If we have a variable offset, the known alignment
  2415.          is only that of the innermost structure containing the field.
  2416.          (Actually, we could sometimes do better by using the
  2417.          align of an element of the innermost array, but no need.)  */
  2418.       if (TREE_CODE (to) == COMPONENT_REF
  2419.           || TREE_CODE (to) == BIT_FIELD_REF)
  2420.         alignment
  2421.           = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (to, 0))) / BITS_PER_UNIT;
  2422.     }
  2423.       if (volatilep)
  2424.     {
  2425.       if (GET_CODE (to_rtx) == MEM)
  2426.         MEM_VOLATILE_P (to_rtx) = 1;
  2427. #if 0  /* This was turned off because, when a field is volatile
  2428.       in an object which is not volatile, the object may be in a register,
  2429.       and then we would abort over here.  */
  2430.       else
  2431.         abort ();
  2432. #endif
  2433.     }
  2434.  
  2435.       result = store_field (to_rtx, bitsize, bitpos, mode1, from,
  2436.                 (want_value
  2437.                  /* Spurious cast makes HPUX compiler happy.  */
  2438.                  ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
  2439.                  : VOIDmode),
  2440.                 unsignedp,
  2441.                 /* Required alignment of containing datum.  */
  2442.                 alignment,
  2443.                 int_size_in_bytes (TREE_TYPE (tem)));
  2444.       preserve_temp_slots (result);
  2445.       free_temp_slots ();
  2446.       pop_temp_slots ();
  2447.  
  2448.       /* If the value is meaningful, convert RESULT to the proper mode.
  2449.      Otherwise, return nothing.  */
  2450.       return (want_value ? convert_modes (TYPE_MODE (TREE_TYPE (to)),
  2451.                       TYPE_MODE (TREE_TYPE (from)),
  2452.                       result,
  2453.                       TREE_UNSIGNED (TREE_TYPE (to)))
  2454.           : NULL_RTX);
  2455.     }
  2456.  
  2457.   /* If the rhs is a function call and its value is not an aggregate,
  2458.      call the function before we start to compute the lhs.
  2459.      This is needed for correct code for cases such as
  2460.      val = setjmp (buf) on machines where reference to val
  2461.      requires loading up part of an address in a separate insn.
  2462.  
  2463.      Don't do this if TO is a VAR_DECL whose DECL_RTL is REG since it might be
  2464.      a promoted variable where the zero- or sign- extension needs to be done.
  2465.      Handling this in the normal way is safe because no computation is done
  2466.      before the call.  */
  2467.   if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from)
  2468.       && ! (TREE_CODE (to) == VAR_DECL && GET_CODE (DECL_RTL (to)) == REG))
  2469.     {
  2470.       rtx value;
  2471.  
  2472.       push_temp_slots ();
  2473.       value = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2474.       if (to_rtx == 0)
  2475.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, 0);
  2476.       emit_move_insn (to_rtx, value);
  2477.       preserve_temp_slots (to_rtx);
  2478.       free_temp_slots ();
  2479.       pop_temp_slots ();
  2480.       return want_value ? to_rtx : NULL_RTX;
  2481.     }
  2482.  
  2483.   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.
  2484.      Don't re-expand if it was expanded already (in COMPONENT_REF case).  */
  2485.  
  2486.   if (to_rtx == 0)
  2487.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, 0);
  2488.  
  2489.   /* Don't move directly into a return register.  */
  2490.   if (TREE_CODE (to) == RESULT_DECL && GET_CODE (to_rtx) == REG)
  2491.     {
  2492.       rtx temp;
  2493.  
  2494.       push_temp_slots ();
  2495.       temp = expand_expr (from, 0, GET_MODE (to_rtx), 0);
  2496.       emit_move_insn (to_rtx, temp);
  2497.       preserve_temp_slots (to_rtx);
  2498.       free_temp_slots ();
  2499.       pop_temp_slots ();
  2500.       return want_value ? to_rtx : NULL_RTX;
  2501.     }
  2502.  
  2503.   /* In case we are returning the contents of an object which overlaps
  2504.      the place the value is being stored, use a safe function when copying
  2505.      a value through a pointer into a structure value return block.  */
  2506.   if (TREE_CODE (to) == RESULT_DECL && TREE_CODE (from) == INDIRECT_REF
  2507.       && current_function_returns_struct
  2508.       && !current_function_returns_pcc_struct)
  2509.     {
  2510.       rtx from_rtx, size;
  2511.  
  2512.       push_temp_slots ();
  2513.       size = expr_size (from);
  2514.       from_rtx = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2515.  
  2516. #ifdef TARGET_MEM_FUNCTIONS
  2517.       emit_library_call (memcpy_libfunc, 0,
  2518.              VOIDmode, 3, XEXP (to_rtx, 0), Pmode,
  2519.              XEXP (from_rtx, 0), Pmode,
  2520.              convert_to_mode (TYPE_MODE (sizetype),
  2521.                       size, TREE_UNSIGNED (sizetype)),
  2522.              TYPE_MODE (sizetype));
  2523. #else
  2524.       emit_library_call (bcopy_libfunc, 0,
  2525.              VOIDmode, 3, XEXP (from_rtx, 0), Pmode,
  2526.              XEXP (to_rtx, 0), Pmode,
  2527.              convert_to_mode (TYPE_MODE (sizetype),
  2528.                       size, TREE_UNSIGNED (sizetype)),
  2529.              TYPE_MODE (sizetype));
  2530. #endif
  2531.  
  2532.       preserve_temp_slots (to_rtx);
  2533.       free_temp_slots ();
  2534.       pop_temp_slots ();
  2535.       return want_value ? to_rtx : NULL_RTX;
  2536.     }
  2537.  
  2538.   /* Compute FROM and store the value in the rtx we got.  */
  2539.  
  2540.   push_temp_slots ();
  2541.   result = store_expr (from, to_rtx, want_value);
  2542.   preserve_temp_slots (result);
  2543.   free_temp_slots ();
  2544.   pop_temp_slots ();
  2545.   return want_value ? result : NULL_RTX;
  2546. }
  2547.  
  2548. /* Generate code for computing expression EXP,
  2549.    and storing the value into TARGET.
  2550.    TARGET may contain a QUEUED rtx.
  2551.  
  2552.    If WANT_VALUE is nonzero, return a copy of the value
  2553.    not in TARGET, so that we can be sure to use the proper
  2554.    value in a containing expression even if TARGET has something
  2555.    else stored in it.  If possible, we copy the value through a pseudo
  2556.    and return that pseudo.  Or, if the value is constant, we try to
  2557.    return the constant.  In some cases, we return a pseudo
  2558.    copied *from* TARGET.
  2559.  
  2560.    If the mode is BLKmode then we may return TARGET itself.
  2561.    It turns out that in BLKmode it doesn't cause a problem.
  2562.    because C has no operators that could combine two different
  2563.    assignments into the same BLKmode object with different values
  2564.    with no sequence point.  Will other languages need this to
  2565.    be more thorough?
  2566.  
  2567.    If WANT_VALUE is 0, we return NULL, to make sure
  2568.    to catch quickly any cases where the caller uses the value
  2569.    and fails to set WANT_VALUE.  */
  2570.  
  2571. rtx
  2572. store_expr (exp, target, want_value)
  2573.      register tree exp;
  2574.      register rtx target;
  2575.      int want_value;
  2576. {
  2577.   register rtx temp;
  2578.   int dont_return_target = 0;
  2579.  
  2580.   if (TREE_CODE (exp) == COMPOUND_EXPR)
  2581.     {
  2582.       /* Perform first part of compound expression, then assign from second
  2583.      part.  */
  2584.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  2585.       emit_queue ();
  2586.       return store_expr (TREE_OPERAND (exp, 1), target, want_value);
  2587.     }
  2588.   else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode)
  2589.     {
  2590.       /* For conditional expression, get safe form of the target.  Then
  2591.      test the condition, doing the appropriate assignment on either
  2592.      side.  This avoids the creation of unnecessary temporaries.
  2593.      For non-BLKmode, it is more efficient not to do this.  */
  2594.  
  2595.       rtx lab1 = gen_label_rtx (), lab2 = gen_label_rtx ();
  2596.  
  2597.       emit_queue ();
  2598.       target = protect_from_queue (target, 1);
  2599.  
  2600.       NO_DEFER_POP;
  2601.       jumpifnot (TREE_OPERAND (exp, 0), lab1);
  2602.       store_expr (TREE_OPERAND (exp, 1), target, 0);
  2603.       emit_queue ();
  2604.       emit_jump_insn (gen_jump (lab2));
  2605.       emit_barrier ();
  2606.       emit_label (lab1);
  2607.       store_expr (TREE_OPERAND (exp, 2), target, 0);
  2608.       emit_queue ();
  2609.       emit_label (lab2);
  2610.       OK_DEFER_POP;
  2611.       return want_value ? target : NULL_RTX;
  2612.     }
  2613.   else if (want_value && GET_CODE (target) == MEM && ! MEM_VOLATILE_P (target)
  2614.        && GET_MODE (target) != BLKmode)
  2615.     /* If target is in memory and caller wants value in a register instead,
  2616.        arrange that.  Pass TARGET as target for expand_expr so that,
  2617.        if EXP is another assignment, WANT_VALUE will be nonzero for it.
  2618.        We know expand_expr will not use the target in that case.
  2619.        Don't do this if TARGET is volatile because we are supposed
  2620.        to write it and then read it.  */
  2621.     {
  2622.       temp = expand_expr (exp, cse_not_expected ? NULL_RTX : target,
  2623.               GET_MODE (target), 0);
  2624.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  2625.     temp = copy_to_reg (temp);
  2626.       dont_return_target = 1;
  2627.     }
  2628.   else if (queued_subexp_p (target))
  2629.     /* If target contains a postincrement, let's not risk
  2630.        using it as the place to generate the rhs.  */
  2631.     {
  2632.       if (GET_MODE (target) != BLKmode && GET_MODE (target) != VOIDmode)
  2633.     {
  2634.       /* Expand EXP into a new pseudo.  */
  2635.       temp = gen_reg_rtx (GET_MODE (target));
  2636.       temp = expand_expr (exp, temp, GET_MODE (target), 0);
  2637.     }
  2638.       else
  2639.     temp = expand_expr (exp, NULL_RTX, GET_MODE (target), 0);
  2640.  
  2641.       /* If target is volatile, ANSI requires accessing the value
  2642.      *from* the target, if it is accessed.  So make that happen.
  2643.      In no case return the target itself.  */
  2644.       if (! MEM_VOLATILE_P (target) && want_value)
  2645.     dont_return_target = 1;
  2646.     }
  2647.   else if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
  2648.     /* If this is an scalar in a register that is stored in a wider mode
  2649.        than the declared mode, compute the result into its declared mode
  2650.        and then convert to the wider mode.  Our value is the computed
  2651.        expression.  */
  2652.     {
  2653.       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  2654.  
  2655.       /* If TEMP is a volatile MEM and we want a result value, make
  2656.      the access now so it gets done only once.  */
  2657.       if (GET_CODE (temp) == MEM && MEM_VOLATILE_P (temp))
  2658.     temp = copy_to_reg (temp);
  2659.  
  2660.       /* If TEMP is a VOIDmode constant, use convert_modes to make
  2661.      sure that we properly convert it.  */
  2662.       if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
  2663.     temp = convert_modes (GET_MODE (SUBREG_REG (target)),
  2664.                   TYPE_MODE (TREE_TYPE (exp)), temp,
  2665.                   SUBREG_PROMOTED_UNSIGNED_P (target));
  2666.  
  2667.       convert_move (SUBREG_REG (target), temp,
  2668.             SUBREG_PROMOTED_UNSIGNED_P (target));
  2669.       return want_value ? temp : NULL_RTX;
  2670.     }
  2671.   else
  2672.     {
  2673.       temp = expand_expr (exp, target, GET_MODE (target), 0);
  2674.       /* Return TARGET if it's a specified hardware register.
  2675.      If TARGET is a volatile mem ref, either return TARGET
  2676.      or return a reg copied *from* TARGET; ANSI requires this.
  2677.  
  2678.      Otherwise, if TEMP is not TARGET, return TEMP
  2679.      if it is constant (for efficiency),
  2680.      or if we really want the correct value.  */
  2681.       if (!(target && GET_CODE (target) == REG
  2682.         && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2683.       && !(GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  2684.       && temp != target
  2685.       && (CONSTANT_P (temp) || want_value))
  2686.     dont_return_target = 1;
  2687.     }
  2688.  
  2689.   /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
  2690.      the same as that of TARGET, adjust the constant.  This is needed, for
  2691.      example, in case it is a CONST_DOUBLE and we want only a word-sized
  2692.      value.  */
  2693.   if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode
  2694.       && TREE_CODE (exp) != ERROR_MARK
  2695.       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
  2696.     temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)),
  2697.               temp, TREE_UNSIGNED (TREE_TYPE (exp)));
  2698.  
  2699.   /* If value was not generated in the target, store it there.
  2700.      Convert the value to TARGET's type first if nec.  */
  2701.  
  2702.   if (temp != target && TREE_CODE (exp) != ERROR_MARK)
  2703.     {
  2704.       target = protect_from_queue (target, 1);
  2705.       if (GET_MODE (temp) != GET_MODE (target)
  2706.       && GET_MODE (temp) != VOIDmode)
  2707.     {
  2708.       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2709.       if (dont_return_target)
  2710.         {
  2711.           /* In this case, we will return TEMP,
  2712.          so make sure it has the proper mode.
  2713.          But don't forget to store the value into TARGET.  */
  2714.           temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
  2715.           emit_move_insn (target, temp);
  2716.         }
  2717.       else
  2718.         convert_move (target, temp, unsignedp);
  2719.     }
  2720.  
  2721.       else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST)
  2722.     {
  2723.       /* Handle copying a string constant into an array.
  2724.          The string constant may be shorter than the array.
  2725.          So copy just the string's actual length, and clear the rest.  */
  2726.       rtx size;
  2727.  
  2728.       /* Get the size of the data type of the string,
  2729.          which is actually the size of the target.  */
  2730.       size = expr_size (exp);
  2731.       if (GET_CODE (size) == CONST_INT
  2732.           && INTVAL (size) < TREE_STRING_LENGTH (exp))
  2733.         emit_block_move (target, temp, size,
  2734.                  TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2735.       else
  2736.         {
  2737.           /* Compute the size of the data to copy from the string.  */
  2738.           tree copy_size
  2739.         = size_binop (MIN_EXPR,
  2740.                   make_tree (sizetype, size),
  2741.                   convert (sizetype,
  2742.                        build_int_2 (TREE_STRING_LENGTH (exp), 0)));
  2743.           rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX,
  2744.                            VOIDmode, 0);
  2745.           rtx label = 0;
  2746.  
  2747.           /* Copy that much.  */
  2748.           emit_block_move (target, temp, copy_size_rtx,
  2749.                    TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2750.  
  2751.           /* Figure out how much is left in TARGET
  2752.          that we have to clear.  */
  2753.           if (GET_CODE (copy_size_rtx) == CONST_INT)
  2754.         {
  2755.           temp = plus_constant (XEXP (target, 0),
  2756.                     TREE_STRING_LENGTH (exp));
  2757.           size = plus_constant (size,
  2758.                     - TREE_STRING_LENGTH (exp));
  2759.         }
  2760.           else
  2761.         {
  2762.           enum machine_mode size_mode = Pmode;
  2763.  
  2764.           temp = force_reg (Pmode, XEXP (target, 0));
  2765.           temp = expand_binop (size_mode, add_optab, temp,
  2766.                        copy_size_rtx, NULL_RTX, 0,
  2767.                        OPTAB_LIB_WIDEN);
  2768.  
  2769.           size = expand_binop (size_mode, sub_optab, size,
  2770.                        copy_size_rtx, NULL_RTX, 0,
  2771.                        OPTAB_LIB_WIDEN);
  2772.  
  2773.           emit_cmp_insn (size, const0_rtx, LT, NULL_RTX,
  2774.                  GET_MODE (size), 0, 0);
  2775.           label = gen_label_rtx ();
  2776.           emit_jump_insn (gen_blt (label));
  2777.         }
  2778.  
  2779.           if (size != const0_rtx)
  2780.         {
  2781. #ifdef TARGET_MEM_FUNCTIONS
  2782.           emit_library_call (memset_libfunc, 0, VOIDmode, 3,
  2783.                      temp, Pmode, const0_rtx, Pmode, size, Pmode);
  2784. #else
  2785.           emit_library_call (bzero_libfunc, 0, VOIDmode, 2,
  2786.                      temp, Pmode, size, Pmode);
  2787. #endif
  2788.         }
  2789.           if (label)
  2790.         emit_label (label);
  2791.         }
  2792.     }
  2793.       else if (GET_MODE (temp) == BLKmode)
  2794.     emit_block_move (target, temp, expr_size (exp),
  2795.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2796.       else
  2797.     emit_move_insn (target, temp);
  2798.     }
  2799.  
  2800.   /* If we don't want a value, return NULL_RTX.  */
  2801.   if (! want_value)
  2802.     return NULL_RTX;
  2803.  
  2804.   /* If we are supposed to return TEMP, do so as long as it isn't a MEM.
  2805.      ??? The latter test doesn't seem to make sense.  */
  2806.   else if (dont_return_target && GET_CODE (temp) != MEM)
  2807.     return temp;
  2808.  
  2809.   /* Return TARGET itself if it is a hard register.  */
  2810.   else if (want_value && GET_MODE (target) != BLKmode
  2811.        && ! (GET_CODE (target) == REG
  2812.          && REGNO (target) < FIRST_PSEUDO_REGISTER))
  2813.     return copy_to_reg (target);
  2814.   
  2815.   else
  2816.     return target;
  2817. }
  2818.  
  2819. /* Store the value of constructor EXP into the rtx TARGET.
  2820.    TARGET is either a REG or a MEM.  */
  2821.  
  2822. static void
  2823. store_constructor (exp, target)
  2824.      tree exp;
  2825.      rtx target;
  2826. {
  2827.   tree type = TREE_TYPE (exp);
  2828.  
  2829.   /* We know our target cannot conflict, since safe_from_p has been called.  */
  2830. #if 0
  2831.   /* Don't try copying piece by piece into a hard register
  2832.      since that is vulnerable to being clobbered by EXP.
  2833.      Instead, construct in a pseudo register and then copy it all.  */
  2834.   if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2835.     {
  2836.       rtx temp = gen_reg_rtx (GET_MODE (target));
  2837.       store_constructor (exp, temp);
  2838.       emit_move_insn (target, temp);
  2839.       return;
  2840.     }
  2841. #endif
  2842.  
  2843.   if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
  2844.       || TREE_CODE (type) == QUAL_UNION_TYPE)
  2845.     {
  2846.       register tree elt;
  2847.  
  2848.       /* Inform later passes that the whole union value is dead.  */
  2849.       if (TREE_CODE (type) == UNION_TYPE
  2850.       || TREE_CODE (type) == QUAL_UNION_TYPE)
  2851.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2852.  
  2853.       /* If we are building a static constructor into a register,
  2854.      set the initial value as zero so we can fold the value into
  2855.      a constant.  */
  2856.       else if (GET_CODE (target) == REG && TREE_STATIC (exp))
  2857.     emit_move_insn (target, const0_rtx);
  2858.  
  2859.       /* If the constructor has fewer fields than the structure,
  2860.      clear the whole structure first.  */
  2861.       else if (list_length (CONSTRUCTOR_ELTS (exp))
  2862.            != list_length (TYPE_FIELDS (type)))
  2863.     clear_storage (target, int_size_in_bytes (type));
  2864.       else
  2865.     /* Inform later passes that the old value is dead.  */
  2866.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2867.  
  2868.       /* Store each element of the constructor into
  2869.      the corresponding field of TARGET.  */
  2870.  
  2871.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  2872.     {
  2873.       register tree field = TREE_PURPOSE (elt);
  2874.       register enum machine_mode mode;
  2875.       int bitsize;
  2876.       int bitpos = 0;
  2877.       int unsignedp;
  2878.       tree pos, constant = 0, offset = 0;
  2879.       rtx to_rtx = target;
  2880.  
  2881.       /* Just ignore missing fields.
  2882.          We cleared the whole structure, above,
  2883.          if any fields are missing.  */
  2884.       if (field == 0)
  2885.         continue;
  2886.  
  2887.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field));
  2888.       unsignedp = TREE_UNSIGNED (field);
  2889.       mode = DECL_MODE (field);
  2890.       if (DECL_BIT_FIELD (field))
  2891.         mode = VOIDmode;
  2892.  
  2893.       pos = DECL_FIELD_BITPOS (field);
  2894.       if (TREE_CODE (pos) == INTEGER_CST)
  2895.         constant = pos;
  2896.       else if (TREE_CODE (pos) == PLUS_EXPR
  2897.            && TREE_CODE (TREE_OPERAND (pos, 1)) == INTEGER_CST)
  2898.         constant = TREE_OPERAND (pos, 1), offset = TREE_OPERAND (pos, 0);
  2899.       else
  2900.         offset = pos;
  2901.  
  2902.       if (constant)
  2903.         bitpos = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  2904.  
  2905.       if (offset)
  2906.         {
  2907.           rtx offset_rtx;
  2908.  
  2909.           if (contains_placeholder_p (offset))
  2910.         offset = build (WITH_RECORD_EXPR, sizetype,
  2911.                 offset, exp);
  2912.  
  2913.           offset = size_binop (FLOOR_DIV_EXPR, offset,
  2914.                    size_int (BITS_PER_UNIT));
  2915.  
  2916.           offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  2917.           if (GET_CODE (to_rtx) != MEM)
  2918.         abort ();
  2919.  
  2920.           to_rtx
  2921.         = change_address (to_rtx, VOIDmode,
  2922.                   gen_rtx (PLUS, Pmode, XEXP (to_rtx, 0),
  2923.                        force_reg (Pmode, offset_rtx)));
  2924.         }
  2925.  
  2926.       store_field (to_rtx, bitsize, bitpos, mode, TREE_VALUE (elt),
  2927.                /* The alignment of TARGET is
  2928.               at least what its type requires.  */
  2929.                VOIDmode, 0,
  2930.                TYPE_ALIGN (type) / BITS_PER_UNIT,
  2931.                int_size_in_bytes (type));
  2932.     }
  2933.     }
  2934.   else if (TREE_CODE (type) == ARRAY_TYPE)
  2935.     {
  2936.       register tree elt;
  2937.       register int i;
  2938.       tree domain = TYPE_DOMAIN (type);
  2939.       HOST_WIDE_INT minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  2940.       HOST_WIDE_INT maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  2941.       tree elttype = TREE_TYPE (type);
  2942.  
  2943.       /* If the constructor has fewer fields than the structure,
  2944.      clear the whole structure first.  Similarly if this this is
  2945.      static constructor of a non-BLKmode object.  */
  2946.  
  2947.       if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1
  2948.       || (GET_CODE (target) == REG && TREE_STATIC (exp)))
  2949.     clear_storage (target, int_size_in_bytes (type));
  2950.       else
  2951.     /* Inform later passes that the old value is dead.  */
  2952.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2953.  
  2954.       /* Store each element of the constructor into
  2955.      the corresponding element of TARGET, determined
  2956.      by counting the elements.  */
  2957.       for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
  2958.        elt;
  2959.        elt = TREE_CHAIN (elt), i++)
  2960.     {
  2961.       register enum machine_mode mode;
  2962.       int bitsize;
  2963.       int bitpos;
  2964.       int unsignedp;
  2965.       tree index = TREE_PURPOSE (elt);
  2966.       rtx xtarget = target;
  2967.  
  2968.       mode = TYPE_MODE (elttype);
  2969.       bitsize = GET_MODE_BITSIZE (mode);
  2970.       unsignedp = TREE_UNSIGNED (elttype);
  2971.  
  2972.       if (index != 0 && TREE_CODE (index) != INTEGER_CST)
  2973.         {
  2974.           /* We don't currently allow variable indices in a
  2975.          C initializer, but let's try here to support them.  */
  2976.           rtx pos_rtx, addr, xtarget;
  2977.           tree position;
  2978.  
  2979.           position = size_binop (MULT_EXPR, index, TYPE_SIZE (elttype));
  2980.           pos_rtx = expand_expr (position, 0, VOIDmode, 0);
  2981.           addr = gen_rtx (PLUS, Pmode, XEXP (target, 0), pos_rtx);
  2982.           xtarget = change_address (target, mode, addr);
  2983.           store_expr (TREE_VALUE (elt), xtarget, 0);
  2984.         }
  2985.       else
  2986.         {
  2987.           if (index != 0)
  2988.         bitpos = ((TREE_INT_CST_LOW (index) - minelt)
  2989.               * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  2990.           else
  2991.         bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  2992.  
  2993.           store_field (xtarget, bitsize, bitpos, mode, TREE_VALUE (elt),
  2994.                /* The alignment of TARGET is
  2995.                   at least what its type requires.  */
  2996.                VOIDmode, 0,
  2997.                TYPE_ALIGN (type) / BITS_PER_UNIT,
  2998.                int_size_in_bytes (type));
  2999.         }
  3000.     }
  3001.     }
  3002.  
  3003.   else
  3004.     abort ();
  3005. }
  3006.  
  3007. /* Store the value of EXP (an expression tree)
  3008.    into a subfield of TARGET which has mode MODE and occupies
  3009.    BITSIZE bits, starting BITPOS bits from the start of TARGET.
  3010.    If MODE is VOIDmode, it means that we are storing into a bit-field.
  3011.  
  3012.    If VALUE_MODE is VOIDmode, return nothing in particular.
  3013.    UNSIGNEDP is not used in this case.
  3014.  
  3015.    Otherwise, return an rtx for the value stored.  This rtx
  3016.    has mode VALUE_MODE if that is convenient to do.
  3017.    In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
  3018.  
  3019.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  3020.    TOTAL_SIZE is the size in bytes of the structure, or -1 if varying.  */
  3021.  
  3022. static rtx
  3023. store_field (target, bitsize, bitpos, mode, exp, value_mode,
  3024.          unsignedp, align, total_size)
  3025.      rtx target;
  3026.      int bitsize, bitpos;
  3027.      enum machine_mode mode;
  3028.      tree exp;
  3029.      enum machine_mode value_mode;
  3030.      int unsignedp;
  3031.      int align;
  3032.      int total_size;
  3033. {
  3034.   HOST_WIDE_INT width_mask = 0;
  3035.  
  3036.   if (bitsize < HOST_BITS_PER_WIDE_INT)
  3037.     width_mask = ((HOST_WIDE_INT) 1 << bitsize) - 1;
  3038.  
  3039.   /* If we are storing into an unaligned field of an aligned union that is
  3040.      in a register, we may have the mode of TARGET being an integer mode but
  3041.      MODE == BLKmode.  In that case, get an aligned object whose size and
  3042.      alignment are the same as TARGET and store TARGET into it (we can avoid
  3043.      the store if the field being stored is the entire width of TARGET).  Then
  3044.      call ourselves recursively to store the field into a BLKmode version of
  3045.      that object.  Finally, load from the object into TARGET.  This is not
  3046.      very efficient in general, but should only be slightly more expensive
  3047.      than the otherwise-required unaligned accesses.  Perhaps this can be
  3048.      cleaned up later.  */
  3049.  
  3050.   if (mode == BLKmode
  3051.       && (GET_CODE (target) == REG || GET_CODE (target) == SUBREG))
  3052.     {
  3053.       rtx object = assign_stack_temp (GET_MODE (target),
  3054.                       GET_MODE_SIZE (GET_MODE (target)), 0);
  3055.       rtx blk_object = copy_rtx (object);
  3056.  
  3057.       MEM_IN_STRUCT_P (object) = 1;
  3058.       MEM_IN_STRUCT_P (blk_object) = 1;
  3059.       PUT_MODE (blk_object, BLKmode);
  3060.  
  3061.       if (bitsize != GET_MODE_BITSIZE (GET_MODE (target)))
  3062.     emit_move_insn (object, target);
  3063.  
  3064.       store_field (blk_object, bitsize, bitpos, mode, exp, VOIDmode, 0,
  3065.            align, total_size);
  3066.  
  3067.       /* Even though we aren't returning target, we need to
  3068.      give it the updated value.  */
  3069.       emit_move_insn (target, object);
  3070.  
  3071.       return blk_object;
  3072.     }
  3073.  
  3074.   /* If the structure is in a register or if the component
  3075.      is a bit field, we cannot use addressing to access it.
  3076.      Use bit-field techniques or SUBREG to store in it.  */
  3077.  
  3078.   if (mode == VOIDmode
  3079.       || (mode != BLKmode && ! direct_store[(int) mode])
  3080.       || GET_CODE (target) == REG
  3081.       || GET_CODE (target) == SUBREG
  3082.       /* If the field isn't aligned enough to store as an ordinary memref,
  3083.      store it as a bit field.  */
  3084.       || (STRICT_ALIGNMENT
  3085.       && align * BITS_PER_UNIT < GET_MODE_ALIGNMENT (mode))
  3086.       || (STRICT_ALIGNMENT && bitpos % GET_MODE_ALIGNMENT (mode) != 0))
  3087.     {
  3088.       rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  3089.  
  3090.       /* Unless MODE is VOIDmode or BLKmode, convert TEMP to
  3091.      MODE.  */
  3092.       if (mode != VOIDmode && mode != BLKmode
  3093.       && mode != TYPE_MODE (TREE_TYPE (exp)))
  3094.     temp = convert_modes (mode, TYPE_MODE (TREE_TYPE (exp)), temp, 1);
  3095.  
  3096.       /* Store the value in the bitfield.  */
  3097.       store_bit_field (target, bitsize, bitpos, mode, temp, align, total_size);
  3098.       if (value_mode != VOIDmode)
  3099.     {
  3100.       /* The caller wants an rtx for the value.  */
  3101.       /* If possible, avoid refetching from the bitfield itself.  */
  3102.       if (width_mask != 0
  3103.           && ! (GET_CODE (target) == MEM && MEM_VOLATILE_P (target)))
  3104.         {
  3105.           tree count;
  3106.           enum machine_mode tmode;
  3107.  
  3108.           if (unsignedp)
  3109.         return expand_and (temp, GEN_INT (width_mask), NULL_RTX);
  3110.           tmode = GET_MODE (temp);
  3111.           if (tmode == VOIDmode)
  3112.         tmode = value_mode;
  3113.           count = build_int_2 (GET_MODE_BITSIZE (tmode) - bitsize, 0);
  3114.           temp = expand_shift (LSHIFT_EXPR, tmode, temp, count, 0, 0);
  3115.           return expand_shift (RSHIFT_EXPR, tmode, temp, count, 0, 0);
  3116.         }
  3117.       return extract_bit_field (target, bitsize, bitpos, unsignedp,
  3118.                     NULL_RTX, value_mode, 0, align,
  3119.                     total_size);
  3120.     }
  3121.       return const0_rtx;
  3122.     }
  3123.   else
  3124.     {
  3125.       rtx addr = XEXP (target, 0);
  3126.       rtx to_rtx;
  3127.  
  3128.       /* If a value is wanted, it must be the lhs;
  3129.      so make the address stable for multiple use.  */
  3130.  
  3131.       if (value_mode != VOIDmode && GET_CODE (addr) != REG
  3132.       && ! CONSTANT_ADDRESS_P (addr)
  3133.       /* A frame-pointer reference is already stable.  */
  3134.       && ! (GET_CODE (addr) == PLUS
  3135.         && GET_CODE (XEXP (addr, 1)) == CONST_INT
  3136.         && (XEXP (addr, 0) == virtual_incoming_args_rtx
  3137.             || XEXP (addr, 0) == virtual_stack_vars_rtx)))
  3138.     addr = copy_to_reg (addr);
  3139.  
  3140.       /* Now build a reference to just the desired component.  */
  3141.  
  3142.       to_rtx = change_address (target, mode,
  3143.                    plus_constant (addr, (bitpos / BITS_PER_UNIT)));
  3144.       MEM_IN_STRUCT_P (to_rtx) = 1;
  3145.  
  3146.       return store_expr (exp, to_rtx, value_mode != VOIDmode);
  3147.     }
  3148. }
  3149.  
  3150. /* Return true if any object containing the innermost array is an unaligned
  3151.    packed structure field.  */
  3152.  
  3153. static int
  3154. get_inner_unaligned_p (exp)
  3155.      tree exp;
  3156. {
  3157.   int needed_alignment = TYPE_ALIGN (TREE_TYPE (exp));
  3158.  
  3159.   while (1)
  3160.     {
  3161.       if (TREE_CODE (exp) == COMPONENT_REF || TREE_CODE (exp) == BIT_FIELD_REF)
  3162.     {
  3163.       if (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
  3164.           < needed_alignment)
  3165.         return 1;
  3166.     }
  3167.       else if (TREE_CODE (exp) != ARRAY_REF
  3168.            && TREE_CODE (exp) != NON_LVALUE_EXPR
  3169.            && ! ((TREE_CODE (exp) == NOP_EXPR
  3170.               || TREE_CODE (exp) == CONVERT_EXPR)
  3171.              && (TYPE_MODE (TREE_TYPE (exp))
  3172.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  3173.     break;
  3174.  
  3175.       exp = TREE_OPERAND (exp, 0);
  3176.     }
  3177.  
  3178.   return 0;
  3179. }
  3180.  
  3181. /* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
  3182.    or an ARRAY_REF, look for nested COMPONENT_REFs, BIT_FIELD_REFs, or
  3183.    ARRAY_REFs and find the ultimate containing object, which we return.
  3184.  
  3185.    We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
  3186.    bit position, and *PUNSIGNEDP to the signedness of the field.
  3187.    If the position of the field is variable, we store a tree
  3188.    giving the variable offset (in units) in *POFFSET.
  3189.    This offset is in addition to the bit position.
  3190.    If the position is not variable, we store 0 in *POFFSET.
  3191.  
  3192.    If any of the extraction expressions is volatile,
  3193.    we store 1 in *PVOLATILEP.  Otherwise we don't change that.
  3194.  
  3195.    If the field is a bit-field, *PMODE is set to VOIDmode.  Otherwise, it
  3196.    is a mode that can be used to access the field.  In that case, *PBITSIZE
  3197.    is redundant.
  3198.  
  3199.    If the field describes a variable-sized object, *PMODE is set to
  3200.    VOIDmode and *PBITSIZE is set to -1.  An access cannot be made in
  3201.    this case, but the address of the object can be found.  */
  3202.  
  3203. tree
  3204. get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode,
  3205.              punsignedp, pvolatilep)
  3206.      tree exp;
  3207.      int *pbitsize;
  3208.      int *pbitpos;
  3209.      tree *poffset;
  3210.      enum machine_mode *pmode;
  3211.      int *punsignedp;
  3212.      int *pvolatilep;
  3213. {
  3214.   tree orig_exp = exp;
  3215.   tree size_tree = 0;
  3216.   enum machine_mode mode = VOIDmode;
  3217.   tree offset = integer_zero_node;
  3218.  
  3219.   if (TREE_CODE (exp) == COMPONENT_REF)
  3220.     {
  3221.       size_tree = DECL_SIZE (TREE_OPERAND (exp, 1));
  3222.       if (! DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  3223.     mode = DECL_MODE (TREE_OPERAND (exp, 1));
  3224.       *punsignedp = TREE_UNSIGNED (TREE_OPERAND (exp, 1));
  3225.     }
  3226.   else if (TREE_CODE (exp) == BIT_FIELD_REF)
  3227.     {
  3228.       size_tree = TREE_OPERAND (exp, 1);
  3229.       *punsignedp = TREE_UNSIGNED (exp);
  3230.     }
  3231.   else
  3232.     {
  3233.       mode = TYPE_MODE (TREE_TYPE (exp));
  3234.       *pbitsize = GET_MODE_BITSIZE (mode);
  3235.       *punsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  3236.     }
  3237.       
  3238.   if (size_tree)
  3239.     {
  3240.       if (TREE_CODE (size_tree) != INTEGER_CST)
  3241.     mode = BLKmode, *pbitsize = -1;
  3242.       else
  3243.     *pbitsize = TREE_INT_CST_LOW (size_tree);
  3244.     }
  3245.  
  3246.   /* Compute cumulative bit-offset for nested component-refs and array-refs,
  3247.      and find the ultimate containing object.  */
  3248.  
  3249.   *pbitpos = 0;
  3250.  
  3251.   while (1)
  3252.     {
  3253.       if (TREE_CODE (exp) == COMPONENT_REF || TREE_CODE (exp) == BIT_FIELD_REF)
  3254.     {
  3255.       tree pos = (TREE_CODE (exp) == COMPONENT_REF
  3256.               ? DECL_FIELD_BITPOS (TREE_OPERAND (exp, 1))
  3257.               : TREE_OPERAND (exp, 2));
  3258.  
  3259.       /* If this field hasn't been filled in yet, don't go
  3260.          past it.  This should only happen when folding expressions
  3261.          made during type construction.  */
  3262.       if (pos == 0)
  3263.         break;
  3264.  
  3265.       if (TREE_CODE (pos) == PLUS_EXPR)
  3266.         {
  3267.           tree constant, var;
  3268.           if (TREE_CODE (TREE_OPERAND (pos, 0)) == INTEGER_CST)
  3269.         {
  3270.           constant = TREE_OPERAND (pos, 0);
  3271.           var = TREE_OPERAND (pos, 1);
  3272.         }
  3273.           else if (TREE_CODE (TREE_OPERAND (pos, 1)) == INTEGER_CST)
  3274.         {
  3275.           constant = TREE_OPERAND (pos, 1);
  3276.           var = TREE_OPERAND (pos, 0);
  3277.         }
  3278.           else
  3279.         abort ();
  3280.  
  3281.           *pbitpos += TREE_INT_CST_LOW (constant);
  3282.           offset = size_binop (PLUS_EXPR, offset,
  3283.                    size_binop (FLOOR_DIV_EXPR, var,
  3284.                            size_int (BITS_PER_UNIT)));
  3285.         }
  3286.       else if (TREE_CODE (pos) == INTEGER_CST)
  3287.         *pbitpos += TREE_INT_CST_LOW (pos);
  3288.       else
  3289.         {
  3290.           /* Assume here that the offset is a multiple of a unit.
  3291.          If not, there should be an explicitly added constant.  */
  3292.           offset = size_binop (PLUS_EXPR, offset,
  3293.                    size_binop (FLOOR_DIV_EXPR, pos,
  3294.                            size_int (BITS_PER_UNIT)));
  3295.         }
  3296.     }
  3297.  
  3298.       else if (TREE_CODE (exp) == ARRAY_REF)
  3299.     {
  3300.       /* This code is based on the code in case ARRAY_REF in expand_expr
  3301.          below.  We assume here that the size of an array element is
  3302.          always an integral multiple of BITS_PER_UNIT.  */
  3303.  
  3304.       tree index = TREE_OPERAND (exp, 1);
  3305.       tree domain = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
  3306.       tree low_bound
  3307.         = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
  3308.       tree index_type = TREE_TYPE (index);
  3309.  
  3310.       if (! integer_zerop (low_bound))
  3311.         index = fold (build (MINUS_EXPR, index_type, index, low_bound));
  3312.  
  3313.       if (TYPE_PRECISION (index_type) != POINTER_SIZE)
  3314.         {
  3315.           index = convert (type_for_size (POINTER_SIZE, 0), index);
  3316.           index_type = TREE_TYPE (index);
  3317.         }
  3318.  
  3319.       index = fold (build (MULT_EXPR, index_type, index,
  3320.                    TYPE_SIZE (TREE_TYPE (exp))));
  3321.  
  3322.       if (TREE_CODE (index) == INTEGER_CST
  3323.           && TREE_INT_CST_HIGH (index) == 0)
  3324.         *pbitpos += TREE_INT_CST_LOW (index);
  3325.       else
  3326.         offset = size_binop (PLUS_EXPR, offset,
  3327.                  size_binop (FLOOR_DIV_EXPR, index,
  3328.                          size_int (BITS_PER_UNIT)));
  3329.     }
  3330.       else if (TREE_CODE (exp) != NON_LVALUE_EXPR
  3331.            && ! ((TREE_CODE (exp) == NOP_EXPR
  3332.               || TREE_CODE (exp) == CONVERT_EXPR)
  3333.              && (TYPE_MODE (TREE_TYPE (exp))
  3334.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  3335.     break;
  3336.  
  3337.       /* If any reference in the chain is volatile, the effect is volatile.  */
  3338.       if (TREE_THIS_VOLATILE (exp))
  3339.     *pvolatilep = 1;
  3340.       exp = TREE_OPERAND (exp, 0);
  3341.     }
  3342.  
  3343.   /* If this was a bit-field, see if there is a mode that allows direct
  3344.      access in case EXP is in memory.  */
  3345.   if (mode == VOIDmode && *pbitsize != 0 && *pbitpos % *pbitsize == 0)
  3346.     {
  3347.       mode = mode_for_size (*pbitsize, MODE_INT, 0);
  3348.       if (mode == BLKmode)
  3349.     mode = VOIDmode;
  3350.     }
  3351.  
  3352.   if (integer_zerop (offset))
  3353.     offset = 0;
  3354.  
  3355.   if (offset != 0 && contains_placeholder_p (offset))
  3356.     offset = build (WITH_RECORD_EXPR, sizetype, offset, orig_exp);
  3357.  
  3358.   *pmode = mode;
  3359.   *poffset = offset;
  3360.   return exp;
  3361. }
  3362.  
  3363. /* Given an rtx VALUE that may contain additions and multiplications,
  3364.    return an equivalent value that just refers to a register or memory.
  3365.    This is done by generating instructions to perform the arithmetic
  3366.    and returning a pseudo-register containing the value.
  3367.  
  3368.    The returned value may be a REG, SUBREG, MEM or constant.  */
  3369.  
  3370. rtx
  3371. force_operand (value, target)
  3372.      rtx value, target;
  3373. {
  3374.   register optab binoptab = 0;
  3375.   /* Use a temporary to force order of execution of calls to
  3376.      `force_operand'.  */
  3377.   rtx tmp;
  3378.   register rtx op2;
  3379.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  3380.   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  3381.  
  3382.   if (GET_CODE (value) == PLUS)
  3383.     binoptab = add_optab;
  3384.   else if (GET_CODE (value) == MINUS)
  3385.     binoptab = sub_optab;
  3386.   else if (GET_CODE (value) == MULT)
  3387.     {
  3388.       op2 = XEXP (value, 1);
  3389.       if (!CONSTANT_P (op2)
  3390.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  3391.     subtarget = 0;
  3392.       tmp = force_operand (XEXP (value, 0), subtarget);
  3393.       return expand_mult (GET_MODE (value), tmp,
  3394.               force_operand (op2, NULL_RTX),
  3395.               target, 0);
  3396.     }
  3397.  
  3398.   if (binoptab)
  3399.     {
  3400.       op2 = XEXP (value, 1);
  3401.       if (!CONSTANT_P (op2)
  3402.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  3403.     subtarget = 0;
  3404.       if (binoptab == sub_optab && GET_CODE (op2) == CONST_INT)
  3405.     {
  3406.       binoptab = add_optab;
  3407.       op2 = negate_rtx (GET_MODE (value), op2);
  3408.     }
  3409.  
  3410.       /* Check for an addition with OP2 a constant integer and our first
  3411.      operand a PLUS of a virtual register and something else.  In that
  3412.      case, we want to emit the sum of the virtual register and the
  3413.      constant first and then add the other value.  This allows virtual
  3414.      register instantiation to simply modify the constant rather than
  3415.      creating another one around this addition.  */
  3416.       if (binoptab == add_optab && GET_CODE (op2) == CONST_INT
  3417.       && GET_CODE (XEXP (value, 0)) == PLUS
  3418.       && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
  3419.       && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
  3420.       && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
  3421.     {
  3422.       rtx temp = expand_binop (GET_MODE (value), binoptab,
  3423.                    XEXP (XEXP (value, 0), 0), op2,
  3424.                    subtarget, 0, OPTAB_LIB_WIDEN);
  3425.       return expand_binop (GET_MODE (value), binoptab, temp,
  3426.                    force_operand (XEXP (XEXP (value, 0), 1), 0),
  3427.                    target, 0, OPTAB_LIB_WIDEN);
  3428.     }
  3429.                    
  3430.       tmp = force_operand (XEXP (value, 0), subtarget);
  3431.       return expand_binop (GET_MODE (value), binoptab, tmp,
  3432.                force_operand (op2, NULL_RTX),
  3433.                target, 0, OPTAB_LIB_WIDEN);
  3434.       /* We give UNSIGNEDP = 0 to expand_binop
  3435.      because the only operations we are expanding here are signed ones.  */
  3436.     }
  3437.   return value;
  3438. }
  3439.  
  3440. /* Subroutine of expand_expr:
  3441.    save the non-copied parts (LIST) of an expr (LHS), and return a list
  3442.    which can restore these values to their previous values,
  3443.    should something modify their storage.  */
  3444.  
  3445. static tree
  3446. save_noncopied_parts (lhs, list)
  3447.      tree lhs;
  3448.      tree list;
  3449. {
  3450.   tree tail;
  3451.   tree parts = 0;
  3452.  
  3453.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  3454.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  3455.       parts = chainon (parts, save_noncopied_parts (lhs, TREE_VALUE (tail)));
  3456.     else
  3457.       {
  3458.     tree part = TREE_VALUE (tail);
  3459.     tree part_type = TREE_TYPE (part);
  3460.     tree to_be_saved = build (COMPONENT_REF, part_type, lhs, part);
  3461.     rtx target = assign_stack_temp (TYPE_MODE (part_type),
  3462.                     int_size_in_bytes (part_type), 0);
  3463.     if (! memory_address_p (TYPE_MODE (part_type), XEXP (target, 0)))
  3464.       target = change_address (target, TYPE_MODE (part_type), NULL_RTX);
  3465.     parts = tree_cons (to_be_saved,
  3466.                build (RTL_EXPR, part_type, NULL_TREE,
  3467.                   (tree) target),
  3468.                parts);
  3469.     store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
  3470.       }
  3471.   return parts;
  3472. }
  3473.  
  3474. /* Subroutine of expand_expr:
  3475.    record the non-copied parts (LIST) of an expr (LHS), and return a list
  3476.    which specifies the initial values of these parts.  */
  3477.  
  3478. static tree
  3479. init_noncopied_parts (lhs, list)
  3480.      tree lhs;
  3481.      tree list;
  3482. {
  3483.   tree tail;
  3484.   tree parts = 0;
  3485.  
  3486.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  3487.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  3488.       parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail)));
  3489.     else
  3490.       {
  3491.     tree part = TREE_VALUE (tail);
  3492.     tree part_type = TREE_TYPE (part);
  3493.     tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part);
  3494.     parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts);
  3495.       }
  3496.   return parts;
  3497. }
  3498.  
  3499. /* Subroutine of expand_expr: return nonzero iff there is no way that
  3500.    EXP can reference X, which is being modified.  */
  3501.  
  3502. static int
  3503. safe_from_p (x, exp)
  3504.      rtx x;
  3505.      tree exp;
  3506. {
  3507.   rtx exp_rtl = 0;
  3508.   int i, nops;
  3509.  
  3510.   if (x == 0)
  3511.     return 1;
  3512.  
  3513.   /* If this is a subreg of a hard register, declare it unsafe, otherwise,
  3514.      find the underlying pseudo.  */
  3515.   if (GET_CODE (x) == SUBREG)
  3516.     {
  3517.       x = SUBREG_REG (x);
  3518.       if (GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  3519.     return 0;
  3520.     }
  3521.  
  3522.   /* If X is a location in the outgoing argument area, it is always safe.  */
  3523.   if (GET_CODE (x) == MEM
  3524.       && (XEXP (x, 0) == virtual_outgoing_args_rtx
  3525.       || (GET_CODE (XEXP (x, 0)) == PLUS
  3526.           && XEXP (XEXP (x, 0), 0) == virtual_outgoing_args_rtx)))
  3527.     return 1;
  3528.  
  3529.   switch (TREE_CODE_CLASS (TREE_CODE (exp)))
  3530.     {
  3531.     case 'd':
  3532.       exp_rtl = DECL_RTL (exp);
  3533.       break;
  3534.  
  3535.     case 'c':
  3536.       return 1;
  3537.  
  3538.     case 'x':
  3539.       if (TREE_CODE (exp) == TREE_LIST)
  3540.     return ((TREE_VALUE (exp) == 0
  3541.          || safe_from_p (x, TREE_VALUE (exp)))
  3542.         && (TREE_CHAIN (exp) == 0
  3543.             || safe_from_p (x, TREE_CHAIN (exp))));
  3544.       else
  3545.     return 0;
  3546.  
  3547.     case '1':
  3548.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  3549.  
  3550.     case '2':
  3551.     case '<':
  3552.       return (safe_from_p (x, TREE_OPERAND (exp, 0))
  3553.           && safe_from_p (x, TREE_OPERAND (exp, 1)));
  3554.  
  3555.     case 'e':
  3556.     case 'r':
  3557.       /* Now do code-specific tests.  EXP_RTL is set to any rtx we find in
  3558.      the expression.  If it is set, we conflict iff we are that rtx or
  3559.      both are in memory.  Otherwise, we check all operands of the
  3560.      expression recursively.  */
  3561.  
  3562.       switch (TREE_CODE (exp))
  3563.     {
  3564.     case ADDR_EXPR:
  3565.       return (staticp (TREE_OPERAND (exp, 0))
  3566.           || safe_from_p (x, TREE_OPERAND (exp, 0)));
  3567.  
  3568.     case INDIRECT_REF:
  3569.       if (GET_CODE (x) == MEM)
  3570.         return 0;
  3571.       break;
  3572.  
  3573.     case CALL_EXPR:
  3574.       exp_rtl = CALL_EXPR_RTL (exp);
  3575.       if (exp_rtl == 0)
  3576.         {
  3577.           /* Assume that the call will clobber all hard registers and
  3578.          all of memory.  */
  3579.           if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  3580.           || GET_CODE (x) == MEM)
  3581.         return 0;
  3582.         }
  3583.  
  3584.       break;
  3585.  
  3586.     case RTL_EXPR:
  3587.       exp_rtl = RTL_EXPR_RTL (exp);
  3588.       if (exp_rtl == 0)
  3589.         /* We don't know what this can modify.  */
  3590.         return 0;
  3591.  
  3592.       break;
  3593.  
  3594.     case WITH_CLEANUP_EXPR:
  3595.       exp_rtl = RTL_EXPR_RTL (exp);
  3596.       break;
  3597.  
  3598.     case CLEANUP_POINT_EXPR:
  3599.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  3600.  
  3601.     case SAVE_EXPR:
  3602.       exp_rtl = SAVE_EXPR_RTL (exp);
  3603.       break;
  3604.  
  3605.     case BIND_EXPR:
  3606.       /* The only operand we look at is operand 1.  The rest aren't
  3607.          part of the expression.  */
  3608.       return safe_from_p (x, TREE_OPERAND (exp, 1));
  3609.  
  3610.     case METHOD_CALL_EXPR:
  3611.       /* This takes a rtx argument, but shouldn't appear here. */
  3612.       abort ();
  3613.     }
  3614.  
  3615.       /* If we have an rtx, we do not need to scan our operands.  */
  3616.       if (exp_rtl)
  3617.     break;
  3618.  
  3619.       nops = tree_code_length[(int) TREE_CODE (exp)];
  3620.       for (i = 0; i < nops; i++)
  3621.     if (TREE_OPERAND (exp, i) != 0
  3622.         && ! safe_from_p (x, TREE_OPERAND (exp, i)))
  3623.       return 0;
  3624.     }
  3625.  
  3626.   /* If we have an rtl, find any enclosed object.  Then see if we conflict
  3627.      with it.  */
  3628.   if (exp_rtl)
  3629.     {
  3630.       if (GET_CODE (exp_rtl) == SUBREG)
  3631.     {
  3632.       exp_rtl = SUBREG_REG (exp_rtl);
  3633.       if (GET_CODE (exp_rtl) == REG
  3634.           && REGNO (exp_rtl) < FIRST_PSEUDO_REGISTER)
  3635.         return 0;
  3636.     }
  3637.  
  3638.       /* If the rtl is X, then it is not safe.  Otherwise, it is unless both
  3639.      are memory and EXP is not readonly.  */
  3640.       return ! (rtx_equal_p (x, exp_rtl)
  3641.         || (GET_CODE (x) == MEM && GET_CODE (exp_rtl) == MEM
  3642.             && ! TREE_READONLY (exp)));
  3643.     }
  3644.  
  3645.   /* If we reach here, it is safe.  */
  3646.   return 1;
  3647. }
  3648.  
  3649. /* Subroutine of expand_expr: return nonzero iff EXP is an
  3650.    expression whose type is statically determinable.  */
  3651.  
  3652. static int
  3653. fixed_type_p (exp)
  3654.      tree exp;
  3655. {
  3656.   if (TREE_CODE (exp) == PARM_DECL
  3657.       || TREE_CODE (exp) == VAR_DECL
  3658.       || TREE_CODE (exp) == CALL_EXPR || TREE_CODE (exp) == TARGET_EXPR
  3659.       || TREE_CODE (exp) == COMPONENT_REF
  3660.       || TREE_CODE (exp) == ARRAY_REF)
  3661.     return 1;
  3662.   return 0;
  3663. }
  3664.  
  3665. /* expand_expr: generate code for computing expression EXP.
  3666.    An rtx for the computed value is returned.  The value is never null.
  3667.    In the case of a void EXP, const0_rtx is returned.
  3668.  
  3669.    The value may be stored in TARGET if TARGET is nonzero.
  3670.    TARGET is just a suggestion; callers must assume that
  3671.    the rtx returned may not be the same as TARGET.
  3672.  
  3673.    If TARGET is CONST0_RTX, it means that the value will be ignored.
  3674.  
  3675.    If TMODE is not VOIDmode, it suggests generating the
  3676.    result in mode TMODE.  But this is done only when convenient.
  3677.    Otherwise, TMODE is ignored and the value generated in its natural mode.
  3678.    TMODE is just a suggestion; callers must assume that
  3679.    the rtx returned may not have mode TMODE.
  3680.  
  3681.    Note that TARGET may have neither TMODE nor MODE.  In that case, it
  3682.    probably will not be used.
  3683.  
  3684.    If MODIFIER is EXPAND_SUM then when EXP is an addition
  3685.    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
  3686.    or a nest of (PLUS ...) and (MINUS ...) where the terms are
  3687.    products as above, or REG or MEM, or constant.
  3688.    Ordinarily in such cases we would output mul or add instructions
  3689.    and then return a pseudo reg containing the sum.
  3690.  
  3691.    EXPAND_INITIALIZER is much like EXPAND_SUM except that
  3692.    it also marks a label as absolutely required (it can't be dead).
  3693.    It also makes a ZERO_EXTEND or SIGN_EXTEND instead of emitting extend insns.
  3694.    This is used for outputting expressions used in initializers.
  3695.  
  3696.    EXPAND_CONST_ADDRESS says that it is okay to return a MEM
  3697.    with a constant address even if that address is not normally legitimate.
  3698.    EXPAND_INITIALIZER and EXPAND_SUM also have this effect.  */
  3699.  
  3700. rtx
  3701. expand_expr (exp, target, tmode, modifier)
  3702.      register tree exp;
  3703.      rtx target;
  3704.      enum machine_mode tmode;
  3705.      enum expand_modifier modifier;
  3706. {
  3707.   /* Chain of pending expressions for PLACEHOLDER_EXPR to replace.
  3708.      This is static so it will be accessible to our recursive callees.  */
  3709.   static tree placeholder_list = 0;
  3710.   register rtx op0, op1, temp;
  3711.   tree type = TREE_TYPE (exp);
  3712.   int unsignedp = TREE_UNSIGNED (type);
  3713.   register enum machine_mode mode = TYPE_MODE (type);
  3714.   register enum tree_code code = TREE_CODE (exp);
  3715.   optab this_optab;
  3716.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  3717.   rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  3718.   rtx original_target = target;
  3719.   /* Maybe defer this until sure not doing bytecode?  */
  3720.   int ignore = (target == const0_rtx
  3721.         || ((code == NON_LVALUE_EXPR || code == NOP_EXPR
  3722.              || code == CONVERT_EXPR || code == REFERENCE_EXPR
  3723.              || code == COND_EXPR)
  3724.             && TREE_CODE (type) == VOID_TYPE));
  3725.   tree context;
  3726.  
  3727.  
  3728.   if (output_bytecode && modifier != EXPAND_INITIALIZER)
  3729.     {
  3730.       bc_expand_expr (exp);
  3731.       return NULL;
  3732.     }
  3733.  
  3734.   /* Don't use hard regs as subtargets, because the combiner
  3735.      can only handle pseudo regs.  */
  3736.   if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
  3737.     subtarget = 0;
  3738.   /* Avoid subtargets inside loops,
  3739.      since they hide some invariant expressions.  */
  3740.   if (preserve_subexpressions_p ())
  3741.     subtarget = 0;
  3742.  
  3743.   /* If we are going to ignore this result, we need only do something
  3744.      if there is a side-effect somewhere in the expression.  If there
  3745.      is, short-circuit the most common cases here.  Note that we must
  3746.      not call expand_expr with anything but const0_rtx in case this
  3747.      is an initial expansion of a size that contains a PLACEHOLDER_EXPR.  */
  3748.  
  3749.   if (ignore)
  3750.     {
  3751.       if (! TREE_SIDE_EFFECTS (exp))
  3752.     return const0_rtx;
  3753.  
  3754.       /* Ensure we reference a volatile object even if value is ignored.  */
  3755.       if (TREE_THIS_VOLATILE (exp)
  3756.       && TREE_CODE (exp) != FUNCTION_DECL
  3757.       && mode != VOIDmode && mode != BLKmode)
  3758.     {
  3759.       temp = expand_expr (exp, NULL_RTX, VOIDmode, modifier);
  3760.       if (GET_CODE (temp) == MEM)
  3761.         temp = copy_to_reg (temp);
  3762.       return const0_rtx;
  3763.     }
  3764.  
  3765.       if (TREE_CODE_CLASS (code) == '1')
  3766.     return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
  3767.                 VOIDmode, modifier);
  3768.       else if (TREE_CODE_CLASS (code) == '2'
  3769.            || TREE_CODE_CLASS (code) == '<')
  3770.     {
  3771.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
  3772.       expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode, modifier);
  3773.       return const0_rtx;
  3774.     }
  3775.       else if ((code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
  3776.            && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
  3777.     /* If the second operand has no side effects, just evaluate
  3778.        the first. */
  3779.     return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
  3780.                 VOIDmode, modifier);
  3781.  
  3782.       target = 0;
  3783.     }
  3784.  
  3785.   /* If will do cse, generate all results into pseudo registers
  3786.      since 1) that allows cse to find more things
  3787.      and 2) otherwise cse could produce an insn the machine
  3788.      cannot support.  */
  3789.  
  3790.   if (! cse_not_expected && mode != BLKmode && target
  3791.       && (GET_CODE (target) != REG || REGNO (target) < FIRST_PSEUDO_REGISTER))
  3792.     target = subtarget;
  3793.  
  3794.   switch (code)
  3795.     {
  3796.     case LABEL_DECL:
  3797.       {
  3798.     tree function = decl_function_context (exp);
  3799.     /* Handle using a label in a containing function.  */
  3800.     if (function != current_function_decl && function != 0)
  3801.       {
  3802.         struct function *p = find_function_data (function);
  3803.         /* Allocate in the memory associated with the function
  3804.            that the label is in.  */
  3805.         push_obstacks (p->function_obstack,
  3806.                p->function_maybepermanent_obstack);
  3807.  
  3808.         p->forced_labels = gen_rtx (EXPR_LIST, VOIDmode,
  3809.                     label_rtx (exp), p->forced_labels);
  3810.         pop_obstacks ();
  3811.       }
  3812.     else if (modifier == EXPAND_INITIALIZER)
  3813.       forced_labels = gen_rtx (EXPR_LIST, VOIDmode,
  3814.                    label_rtx (exp), forced_labels);
  3815.     temp = gen_rtx (MEM, FUNCTION_MODE,
  3816.             gen_rtx (LABEL_REF, Pmode, label_rtx (exp)));
  3817.     if (function != current_function_decl && function != 0)
  3818.       LABEL_REF_NONLOCAL_P (XEXP (temp, 0)) = 1;
  3819.     return temp;
  3820.       }
  3821.  
  3822.     case PARM_DECL:
  3823.       if (DECL_RTL (exp) == 0)
  3824.     {
  3825.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  3826.       return CONST0_RTX (mode);
  3827.     }
  3828.  
  3829.       /* ... fall through ... */
  3830.  
  3831.     case VAR_DECL:
  3832.       /* If a static var's type was incomplete when the decl was written,
  3833.      but the type is complete now, lay out the decl now.  */
  3834.       if (DECL_SIZE (exp) == 0 && TYPE_SIZE (TREE_TYPE (exp)) != 0
  3835.       && (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
  3836.     {
  3837.       push_obstacks_nochange ();
  3838.       end_temporary_allocation ();
  3839.       layout_decl (exp, 0);
  3840.       PUT_MODE (DECL_RTL (exp), DECL_MODE (exp));
  3841.       pop_obstacks ();
  3842.     }
  3843.  
  3844.       /* ... fall through ... */
  3845.  
  3846.     case FUNCTION_DECL:
  3847.     case RESULT_DECL:
  3848.       if (DECL_RTL (exp) == 0)
  3849.     abort ();
  3850.  
  3851.       /* Ensure variable marked as used even if it doesn't go through
  3852.      a parser.  If it hasn't be used yet, write out an external
  3853.      definition.  */
  3854.       if (! TREE_USED (exp))
  3855.     {
  3856.       assemble_external (exp);
  3857.       TREE_USED (exp) = 1;
  3858.     }
  3859.  
  3860.       /* Handle variables inherited from containing functions.  */
  3861.       context = decl_function_context (exp);
  3862.  
  3863.       /* We treat inline_function_decl as an alias for the current function
  3864.      because that is the inline function whose vars, types, etc.
  3865.      are being merged into the current function.
  3866.      See expand_inline_function.  */
  3867.  
  3868.       if (context != 0 && context != current_function_decl
  3869.       && context != inline_function_decl
  3870.       /* If var is static, we don't need a static chain to access it.  */
  3871.       && ! (GET_CODE (DECL_RTL (exp)) == MEM
  3872.         && CONSTANT_P (XEXP (DECL_RTL (exp), 0))))
  3873.     {
  3874.       rtx addr;
  3875.  
  3876.       /* Mark as non-local and addressable.  */
  3877.       DECL_NONLOCAL (exp) = 1;
  3878.       mark_addressable (exp);
  3879.       if (GET_CODE (DECL_RTL (exp)) != MEM)
  3880.         abort ();
  3881.       addr = XEXP (DECL_RTL (exp), 0);
  3882.       if (GET_CODE (addr) == MEM)
  3883.         addr = gen_rtx (MEM, Pmode,
  3884.                 fix_lexical_addr (XEXP (addr, 0), exp));
  3885.       else
  3886.         addr = fix_lexical_addr (addr, exp);
  3887.       return change_address (DECL_RTL (exp), mode, addr);
  3888.     }
  3889.  
  3890.       /* This is the case of an array whose size is to be determined
  3891.      from its initializer, while the initializer is still being parsed.
  3892.      See expand_decl.  */
  3893.  
  3894.       if (GET_CODE (DECL_RTL (exp)) == MEM
  3895.       && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
  3896.     return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
  3897.                    XEXP (DECL_RTL (exp), 0));
  3898.  
  3899.       /* If DECL_RTL is memory, we are in the normal case and either
  3900.      the address is not valid or it is not a register and -fforce-addr
  3901.      is specified, get the address into a register.  */
  3902.  
  3903.       if (GET_CODE (DECL_RTL (exp)) == MEM
  3904.       && modifier != EXPAND_CONST_ADDRESS
  3905.       && modifier != EXPAND_SUM
  3906.       && modifier != EXPAND_INITIALIZER
  3907.       && (! memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
  3908.           || (flag_force_addr
  3909.           && GET_CODE (XEXP (DECL_RTL (exp), 0)) != REG)))
  3910.     return change_address (DECL_RTL (exp), VOIDmode,
  3911.                    copy_rtx (XEXP (DECL_RTL (exp), 0)));
  3912.  
  3913.       /* If the mode of DECL_RTL does not match that of the decl, it
  3914.      must be a promoted value.  We return a SUBREG of the wanted mode,
  3915.      but mark it so that we know that it was already extended.  */
  3916.  
  3917.       if (GET_CODE (DECL_RTL (exp)) == REG
  3918.       && GET_MODE (DECL_RTL (exp)) != mode)
  3919.     {
  3920.       /* Get the signedness used for this variable.  Ensure we get the
  3921.          same mode we got when the variable was declared.  */
  3922.       if (GET_MODE (DECL_RTL (exp))
  3923.           != promote_mode (type, DECL_MODE (exp), &unsignedp, 0))
  3924.         abort ();
  3925.  
  3926.       temp = gen_rtx (SUBREG, mode, DECL_RTL (exp), 0);
  3927.       SUBREG_PROMOTED_VAR_P (temp) = 1;
  3928.       SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  3929.       return temp;
  3930.     }
  3931.  
  3932.       return DECL_RTL (exp);
  3933.  
  3934.     case INTEGER_CST:
  3935.       return immed_double_const (TREE_INT_CST_LOW (exp),
  3936.                  TREE_INT_CST_HIGH (exp),
  3937.                  mode);
  3938.  
  3939.     case CONST_DECL:
  3940.       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
  3941.  
  3942.     case REAL_CST:
  3943.       /* If optimized, generate immediate CONST_DOUBLE
  3944.      which will be turned into memory by reload if necessary. 
  3945.      
  3946.      We used to force a register so that loop.c could see it.  But
  3947.      this does not allow gen_* patterns to perform optimizations with
  3948.      the constants.  It also produces two insns in cases like "x = 1.0;".
  3949.      On most machines, floating-point constants are not permitted in
  3950.      many insns, so we'd end up copying it to a register in any case.
  3951.  
  3952.      Now, we do the copying in expand_binop, if appropriate.  */
  3953.       return immed_real_const (exp);
  3954.  
  3955.     case COMPLEX_CST:
  3956.     case STRING_CST:
  3957.       if (! TREE_CST_RTL (exp))
  3958.     output_constant_def (exp);
  3959.  
  3960.       /* TREE_CST_RTL probably contains a constant address.
  3961.      On RISC machines where a constant address isn't valid,
  3962.      make some insns to get that address into a register.  */
  3963.       if (GET_CODE (TREE_CST_RTL (exp)) == MEM
  3964.       && modifier != EXPAND_CONST_ADDRESS
  3965.       && modifier != EXPAND_INITIALIZER
  3966.       && modifier != EXPAND_SUM
  3967.       && (! memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0))
  3968.           || (flag_force_addr
  3969.           && GET_CODE (XEXP (TREE_CST_RTL (exp), 0)) != REG)))
  3970.     return change_address (TREE_CST_RTL (exp), VOIDmode,
  3971.                    copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
  3972.       return TREE_CST_RTL (exp);
  3973.  
  3974.     case SAVE_EXPR:
  3975.       context = decl_function_context (exp);
  3976.  
  3977.       /* We treat inline_function_decl as an alias for the current function
  3978.      because that is the inline function whose vars, types, etc.
  3979.      are being merged into the current function.
  3980.      See expand_inline_function.  */
  3981.       if (context == current_function_decl || context == inline_function_decl)
  3982.     context = 0;
  3983.  
  3984.       /* If this is non-local, handle it.  */
  3985.       if (context)
  3986.     {
  3987.       temp = SAVE_EXPR_RTL (exp);
  3988.       if (temp && GET_CODE (temp) == REG)
  3989.         {
  3990.           put_var_into_stack (exp);
  3991.           temp = SAVE_EXPR_RTL (exp);
  3992.         }
  3993.       if (temp == 0 || GET_CODE (temp) != MEM)
  3994.         abort ();
  3995.       return change_address (temp, mode,
  3996.                  fix_lexical_addr (XEXP (temp, 0), exp));
  3997.     }
  3998.       if (SAVE_EXPR_RTL (exp) == 0)
  3999.     {
  4000.       if (mode == BLKmode)
  4001.         {
  4002.           temp
  4003.         = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4004.           MEM_IN_STRUCT_P (temp) = AGGREGATE_TYPE_P (type);
  4005.         }
  4006.       else
  4007.         temp = gen_reg_rtx (promote_mode (type, mode, &unsignedp, 0));
  4008.  
  4009.       SAVE_EXPR_RTL (exp) = temp;
  4010.       if (!optimize && GET_CODE (temp) == REG)
  4011.         save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, temp,
  4012.                       save_expr_regs);
  4013.  
  4014.       /* If the mode of TEMP does not match that of the expression, it
  4015.          must be a promoted value.  We pass store_expr a SUBREG of the
  4016.          wanted mode but mark it so that we know that it was already
  4017.          extended.  Note that `unsignedp' was modified above in
  4018.          this case.  */
  4019.  
  4020.       if (GET_CODE (temp) == REG && GET_MODE (temp) != mode)
  4021.         {
  4022.           temp = gen_rtx (SUBREG, mode, SAVE_EXPR_RTL (exp), 0);
  4023.           SUBREG_PROMOTED_VAR_P (temp) = 1;
  4024.           SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4025.         }
  4026.  
  4027.       store_expr (TREE_OPERAND (exp, 0), temp, 0);
  4028.     }
  4029.  
  4030.       /* If the mode of SAVE_EXPR_RTL does not match that of the expression, it
  4031.      must be a promoted value.  We return a SUBREG of the wanted mode,
  4032.      but mark it so that we know that it was already extended. */
  4033.  
  4034.       if (GET_CODE (SAVE_EXPR_RTL (exp)) == REG
  4035.       && GET_MODE (SAVE_EXPR_RTL (exp)) != mode)
  4036.     {
  4037.       /* Compute the signedness and make the proper SUBREG.  */
  4038.       promote_mode (type, mode, &unsignedp, 0);
  4039.       temp = gen_rtx (SUBREG, mode, SAVE_EXPR_RTL (exp), 0);
  4040.       SUBREG_PROMOTED_VAR_P (temp) = 1;
  4041.       SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4042.       return temp;
  4043.     }
  4044.  
  4045.       return SAVE_EXPR_RTL (exp);
  4046.  
  4047.     case PLACEHOLDER_EXPR:
  4048.       /* If there is an object on the head of the placeholder list,
  4049.      see if some object in it's references is of type TYPE.  For
  4050.      further information, see tree.def.  */
  4051.       if (placeholder_list)
  4052.     {
  4053.       tree object;
  4054.       tree old_list = placeholder_list;
  4055.  
  4056.       for (object = TREE_PURPOSE (placeholder_list);
  4057.            TREE_TYPE (object) != type
  4058.            && (TREE_CODE_CLASS (TREE_CODE (object)) == 'r'
  4059.            || TREE_CODE_CLASS (TREE_CODE (object)) == '1'
  4060.            || TREE_CODE_CLASS (TREE_CODE (object)) == '2'
  4061.            || TREE_CODE_CLASS (TREE_CODE (object)) == 'e');
  4062.            object = TREE_OPERAND (object, 0))
  4063.         ;
  4064.  
  4065.       if (object && TREE_TYPE (object) == type)
  4066.         {
  4067.           /* Expand this object skipping the list entries before
  4068.          it was found in case it is also a PLACEHOLDER_EXPR.
  4069.          In that case, we want to translate it using subsequent
  4070.          entries.  */
  4071.           placeholder_list = TREE_CHAIN (placeholder_list);
  4072.           temp = expand_expr (object, original_target, tmode, modifier);
  4073.           placeholder_list = old_list;
  4074.           return temp;
  4075.         }
  4076.     }
  4077.  
  4078.       /* We can't find the object or there was a missing WITH_RECORD_EXPR.  */
  4079.       abort ();
  4080.  
  4081.     case WITH_RECORD_EXPR:
  4082.       /* Put the object on the placeholder list, expand our first operand,
  4083.      and pop the list.  */
  4084.       placeholder_list = tree_cons (TREE_OPERAND (exp, 1), NULL_TREE,
  4085.                     placeholder_list);
  4086.       target = expand_expr (TREE_OPERAND (exp, 0), original_target,
  4087.                 tmode, modifier);
  4088.       placeholder_list = TREE_CHAIN (placeholder_list);
  4089.       return target;
  4090.  
  4091.     case EXIT_EXPR:
  4092.       expand_exit_loop_if_false (NULL_PTR,
  4093.                  invert_truthvalue (TREE_OPERAND (exp, 0)));
  4094.       return const0_rtx;
  4095.  
  4096.     case LOOP_EXPR:
  4097.       push_temp_slots ();
  4098.       expand_start_loop (1);
  4099.       expand_expr_stmt (TREE_OPERAND (exp, 0));
  4100.       expand_end_loop ();
  4101.       pop_temp_slots ();
  4102.  
  4103.       return const0_rtx;
  4104.  
  4105.     case BIND_EXPR:
  4106.       {
  4107.     tree vars = TREE_OPERAND (exp, 0);
  4108.     int vars_need_expansion = 0;
  4109.  
  4110.     /* Need to open a binding contour here because
  4111.        if there are any cleanups they most be contained here.  */
  4112.     expand_start_bindings (0);
  4113.  
  4114.     /* Mark the corresponding BLOCK for output in its proper place.  */
  4115.     if (TREE_OPERAND (exp, 2) != 0
  4116.         && ! TREE_USED (TREE_OPERAND (exp, 2)))
  4117.       insert_block (TREE_OPERAND (exp, 2));
  4118.  
  4119.     /* If VARS have not yet been expanded, expand them now.  */
  4120.     while (vars)
  4121.       {
  4122.         if (DECL_RTL (vars) == 0)
  4123.           {
  4124.         vars_need_expansion = 1;
  4125.         expand_decl (vars);
  4126.           }
  4127.         expand_decl_init (vars);
  4128.         vars = TREE_CHAIN (vars);
  4129.       }
  4130.  
  4131.     temp = expand_expr (TREE_OPERAND (exp, 1), target, tmode, modifier);
  4132.  
  4133.     expand_end_bindings (TREE_OPERAND (exp, 0), 0, 0);
  4134.  
  4135.     return temp;
  4136.       }
  4137.  
  4138.     case RTL_EXPR:
  4139.       if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
  4140.     abort ();
  4141.       emit_insns (RTL_EXPR_SEQUENCE (exp));
  4142.       RTL_EXPR_SEQUENCE (exp) = const0_rtx;
  4143.       preserve_rtl_expr_result (RTL_EXPR_RTL (exp));
  4144.       free_temps_for_rtl_expr (exp);
  4145.       return RTL_EXPR_RTL (exp);
  4146.  
  4147.     case CONSTRUCTOR:
  4148.       /* If we don't need the result, just ensure we evaluate any
  4149.      subexpressions.  */
  4150.       if (ignore)
  4151.     {
  4152.       tree elt;
  4153.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  4154.         expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
  4155.       return const0_rtx;
  4156.     }
  4157.  
  4158.       /* All elts simple constants => refer to a constant in memory.  But
  4159.      if this is a non-BLKmode mode, let it store a field at a time
  4160.      since that should make a CONST_INT or CONST_DOUBLE when we
  4161.      fold.  Likewise, if we have a target we can use, it is best to
  4162.      store directly into the target unless the type is large enough
  4163.      that memcpy will be used.  If we are making an initializer and
  4164.      all operands are constant, put it in memory as well.  */
  4165.       else if ((TREE_STATIC (exp)
  4166.         && ((mode == BLKmode
  4167.              && ! (target != 0 && safe_from_p (target, exp)))
  4168.             || TREE_ADDRESSABLE (exp)
  4169.             || (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
  4170.             && (move_by_pieces_ninsns
  4171.                 (TREE_INT_CST_LOW (TYPE_SIZE (type)),
  4172.                  TYPE_ALIGN (type))
  4173.                 > MOVE_RATIO))))
  4174.            || (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp)))
  4175.     {
  4176.       rtx constructor = output_constant_def (exp);
  4177.       if (modifier != EXPAND_CONST_ADDRESS
  4178.           && modifier != EXPAND_INITIALIZER
  4179.           && modifier != EXPAND_SUM
  4180.           && (! memory_address_p (GET_MODE (constructor),
  4181.                       XEXP (constructor, 0))
  4182.           || (flag_force_addr
  4183.               && GET_CODE (XEXP (constructor, 0)) != REG)))
  4184.         constructor = change_address (constructor, VOIDmode,
  4185.                       XEXP (constructor, 0));
  4186.       return constructor;
  4187.     }
  4188.  
  4189.       else
  4190.     {
  4191.       if (target == 0 || ! safe_from_p (target, exp))
  4192.         {
  4193.           if (mode != BLKmode && ! TREE_ADDRESSABLE (exp))
  4194.         target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4195.           else
  4196.         {
  4197.           target
  4198.             = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4199.           if (AGGREGATE_TYPE_P (type))
  4200.             MEM_IN_STRUCT_P (target) = 1;
  4201.         }
  4202.         }
  4203.       store_constructor (exp, target);
  4204.       return target;
  4205.     }
  4206.  
  4207.     case INDIRECT_REF:
  4208.       {
  4209.     tree exp1 = TREE_OPERAND (exp, 0);
  4210.     tree exp2;
  4211.  
  4212.     /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
  4213.        for  *PTR += ANYTHING  where PTR is put inside the SAVE_EXPR.
  4214.        This code has the same general effect as simply doing
  4215.        expand_expr on the save expr, except that the expression PTR
  4216.        is computed for use as a memory address.  This means different
  4217.        code, suitable for indexing, may be generated.  */
  4218.     if (TREE_CODE (exp1) == SAVE_EXPR
  4219.         && SAVE_EXPR_RTL (exp1) == 0
  4220.         && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK
  4221.         && TYPE_MODE (TREE_TYPE (exp1)) == Pmode
  4222.         && TYPE_MODE (TREE_TYPE (exp2)) == Pmode)
  4223.       {
  4224.         temp = expand_expr (TREE_OPERAND (exp1, 0), NULL_RTX,
  4225.                 VOIDmode, EXPAND_SUM);
  4226.         op0 = memory_address (mode, temp);
  4227.         op0 = copy_all_regs (op0);
  4228.         SAVE_EXPR_RTL (exp1) = op0;
  4229.       }
  4230.     else
  4231.       {
  4232.         op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM);
  4233.         op0 = memory_address (mode, op0);
  4234.       }
  4235.  
  4236.     temp = gen_rtx (MEM, mode, op0);
  4237.     /* If address was computed by addition,
  4238.        mark this as an element of an aggregate.  */
  4239.     if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  4240.         || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
  4241.         && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR)
  4242.         || AGGREGATE_TYPE_P (TREE_TYPE (exp))
  4243.         || (TREE_CODE (exp1) == ADDR_EXPR
  4244.         && (exp2 = TREE_OPERAND (exp1, 0))
  4245.         && AGGREGATE_TYPE_P (TREE_TYPE (exp2))))
  4246.       MEM_IN_STRUCT_P (temp) = 1;
  4247.     MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) | flag_volatile;
  4248. #if 0 /* It is incorrect to set RTX_UNCHANGING_P here, because the fact that
  4249.      a location is accessed through a pointer to const does not mean
  4250.      that the value there can never change.  */
  4251.     RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
  4252. #endif
  4253.     return temp;
  4254.       }
  4255.  
  4256.     case ARRAY_REF:
  4257.       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) != ARRAY_TYPE)
  4258.     abort ();
  4259.  
  4260.       {
  4261.     tree array = TREE_OPERAND (exp, 0);
  4262.     tree domain = TYPE_DOMAIN (TREE_TYPE (array));
  4263.     tree low_bound = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
  4264.     tree index = TREE_OPERAND (exp, 1);
  4265.     tree index_type = TREE_TYPE (index);
  4266.     int i;
  4267.  
  4268.     if (TREE_CODE (low_bound) != INTEGER_CST
  4269.         && contains_placeholder_p (low_bound))
  4270.       low_bound = build (WITH_RECORD_EXPR, sizetype, low_bound, exp);
  4271.  
  4272.     /* Optimize the special-case of a zero lower bound.
  4273.  
  4274.        We convert the low_bound to sizetype to avoid some problems
  4275.        with constant folding.  (E.g. suppose the lower bound is 1,
  4276.        and its mode is QI.  Without the conversion,  (ARRAY
  4277.        +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
  4278.        +INDEX), which becomes (ARRAY+255+INDEX).  Oops!)
  4279.  
  4280.        But sizetype isn't quite right either (especially if
  4281.        the lowbound is negative).  FIXME */
  4282.  
  4283.     if (! integer_zerop (low_bound))
  4284.       index = fold (build (MINUS_EXPR, index_type, index,
  4285.                    convert (sizetype, low_bound)));
  4286.  
  4287.     if ((TREE_CODE (index) != INTEGER_CST
  4288.          || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  4289.         && (! STRICT_ALIGNMENT || ! get_inner_unaligned_p (exp)))
  4290.       {
  4291.         /* Nonconstant array index or nonconstant element size, and
  4292.            not an array in an unaligned (packed) structure field.
  4293.            Generate the tree for *(&array+index) and expand that,
  4294.            except do it in a language-independent way
  4295.            and don't complain about non-lvalue arrays.
  4296.            `mark_addressable' should already have been called
  4297.            for any array for which this case will be reached.  */
  4298.  
  4299.         /* Don't forget the const or volatile flag from the array
  4300.            element. */
  4301.         tree variant_type = build_type_variant (type,
  4302.                             TREE_READONLY (exp),
  4303.                             TREE_THIS_VOLATILE (exp));
  4304.         tree array_adr = build1 (ADDR_EXPR,
  4305.                      build_pointer_type (variant_type), array);
  4306.         tree elt;
  4307.         tree size = size_in_bytes (type);
  4308.  
  4309.         /* Convert the integer argument to a type the same size as a
  4310.            pointer so the multiply won't overflow spuriously.  */
  4311.         if (TYPE_PRECISION (index_type) != POINTER_SIZE)
  4312.           index = convert (type_for_size (POINTER_SIZE, 0), index);
  4313.  
  4314.         if (TREE_CODE (size) != INTEGER_CST
  4315.         && contains_placeholder_p (size))
  4316.           size = build (WITH_RECORD_EXPR, sizetype, size, exp);
  4317.  
  4318.         /* Don't think the address has side effects
  4319.            just because the array does.
  4320.            (In some cases the address might have side effects,
  4321.            and we fail to record that fact here.  However, it should not
  4322.            matter, since expand_expr should not care.)  */
  4323.         TREE_SIDE_EFFECTS (array_adr) = 0;
  4324.  
  4325.         elt = build1 (INDIRECT_REF, type,
  4326.               fold (build (PLUS_EXPR,
  4327.                        TYPE_POINTER_TO (variant_type),
  4328.                        array_adr,
  4329.                        fold (build (MULT_EXPR,
  4330.                             TYPE_POINTER_TO (variant_type),
  4331.                             index, size)))));
  4332.  
  4333.         /* Volatility, etc., of new expression is same as old
  4334.            expression.  */
  4335.         TREE_SIDE_EFFECTS (elt) = TREE_SIDE_EFFECTS (exp);
  4336.         TREE_THIS_VOLATILE (elt) = TREE_THIS_VOLATILE (exp);
  4337.         TREE_READONLY (elt) = TREE_READONLY (exp);
  4338.  
  4339.         return expand_expr (elt, target, tmode, modifier);
  4340.       }
  4341.  
  4342.     /* Fold an expression like: "foo"[2].
  4343.        This is not done in fold so it won't happen inside &.  */
  4344.  
  4345.     if (TREE_CODE (array) == STRING_CST
  4346.         && TREE_CODE (index) == INTEGER_CST
  4347.         && !TREE_INT_CST_HIGH (index)
  4348.         && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (array)
  4349.         && GET_MODE_CLASS (mode) == MODE_INT)
  4350.       return GEN_INT (TREE_STRING_POINTER (array)[i]);
  4351.  
  4352.     /* If this is a constant index into a constant array,
  4353.        just get the value from the array.  Handle both the cases when
  4354.        we have an explicit constructor and when our operand is a variable
  4355.        that was declared const.  */
  4356.  
  4357.     if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array))
  4358.       {
  4359.         if (TREE_CODE (index) == INTEGER_CST
  4360.         && TREE_INT_CST_HIGH (index) == 0)
  4361.           {
  4362.         tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0));
  4363.  
  4364.         i = TREE_INT_CST_LOW (index);
  4365.         while (elem && i--)
  4366.           elem = TREE_CHAIN (elem);
  4367.         if (elem)
  4368.           return expand_expr (fold (TREE_VALUE (elem)), target,
  4369.                       tmode, modifier);
  4370.           }
  4371.       }
  4372.       
  4373.     else if (optimize >= 1
  4374.          && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array)
  4375.          && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array)
  4376.          && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK)
  4377.       {
  4378.         if (TREE_CODE (index) == INTEGER_CST
  4379.         && TREE_INT_CST_HIGH (index) == 0)
  4380.           {
  4381.         tree init = DECL_INITIAL (array);
  4382.  
  4383.         i = TREE_INT_CST_LOW (index);
  4384.         if (TREE_CODE (init) == CONSTRUCTOR)
  4385.           {
  4386.             tree elem = CONSTRUCTOR_ELTS (init);
  4387.  
  4388.             while (elem
  4389.                && !tree_int_cst_equal (TREE_PURPOSE (elem), index))
  4390.               elem = TREE_CHAIN (elem);
  4391.             if (elem)
  4392.               return expand_expr (fold (TREE_VALUE (elem)), target,
  4393.                       tmode, modifier);
  4394.           }
  4395.         else if (TREE_CODE (init) == STRING_CST
  4396.              && i < TREE_STRING_LENGTH (init))
  4397.           return GEN_INT (TREE_STRING_POINTER (init)[i]);
  4398.           }
  4399.       }
  4400.       }
  4401.  
  4402.       /* Treat array-ref with constant index as a component-ref.  */
  4403.  
  4404.     case COMPONENT_REF:
  4405.     case BIT_FIELD_REF:
  4406.       /* If the operand is a CONSTRUCTOR, we can just extract the
  4407.      appropriate field if it is present.  */
  4408.       if (code != ARRAY_REF
  4409.       && TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR)
  4410.     {
  4411.       tree elt;
  4412.  
  4413.       for (elt = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); elt;
  4414.            elt = TREE_CHAIN (elt))
  4415.         if (TREE_PURPOSE (elt) == TREE_OPERAND (exp, 1))
  4416.           return expand_expr (TREE_VALUE (elt), target, tmode, modifier);
  4417.     }
  4418.  
  4419.       {
  4420.     enum machine_mode mode1;
  4421.     int bitsize;
  4422.     int bitpos;
  4423.     tree offset;
  4424.     int volatilep = 0;
  4425.     tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset,
  4426.                     &mode1, &unsignedp, &volatilep);
  4427.     int alignment;
  4428.  
  4429.     /* If we got back the original object, something is wrong.  Perhaps
  4430.        we are evaluating an expression too early.  In any event, don't
  4431.        infinitely recurse.  */
  4432.     if (tem == exp)
  4433.       abort ();
  4434.  
  4435.     /* In some cases, we will be offsetting OP0's address by a constant.
  4436.        So get it as a sum, if possible.  If we will be using it
  4437.        directly in an insn, we validate it.  */
  4438.     op0 = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_SUM);
  4439.  
  4440.     /* If this is a constant, put it into a register if it is a
  4441.        legitimate constant and memory if it isn't.  */
  4442.     if (CONSTANT_P (op0))
  4443.       {
  4444.         enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem));
  4445.         if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0))
  4446.           op0 = force_reg (mode, op0);
  4447.         else
  4448.           op0 = validize_mem (force_const_mem (mode, op0));
  4449.       }
  4450.  
  4451.     alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
  4452.     if (offset != 0)
  4453.       {
  4454.         rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  4455.  
  4456.         if (GET_CODE (op0) != MEM)
  4457.           abort ();
  4458.         op0 = change_address (op0, VOIDmode,
  4459.                   gen_rtx (PLUS, Pmode, XEXP (op0, 0),
  4460.                        force_reg (Pmode, offset_rtx)));
  4461.       /* If we have a variable offset, the known alignment
  4462.          is only that of the innermost structure containing the field.
  4463.          (Actually, we could sometimes do better by using the
  4464.          size of an element of the innermost array, but no need.)  */
  4465.       if (TREE_CODE (exp) == COMPONENT_REF
  4466.           || TREE_CODE (exp) == BIT_FIELD_REF)
  4467.         alignment = (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
  4468.              / BITS_PER_UNIT);
  4469.       }
  4470.  
  4471.     /* Don't forget about volatility even if this is a bitfield.  */
  4472.     if (GET_CODE (op0) == MEM && volatilep && ! MEM_VOLATILE_P (op0))
  4473.       {
  4474.         op0 = copy_rtx (op0);
  4475.         MEM_VOLATILE_P (op0) = 1;
  4476.       }
  4477.  
  4478.     /* In cases where an aligned union has an unaligned object
  4479.        as a field, we might be extracting a BLKmode value from
  4480.        an integer-mode (e.g., SImode) object.  Handle this case
  4481.        by doing the extract into an object as wide as the field
  4482.        (which we know to be the width of a basic mode), then
  4483.        storing into memory, and changing the mode to BLKmode.  */
  4484.     if (mode1 == VOIDmode
  4485.         || (mode1 != BLKmode && ! direct_load[(int) mode1]
  4486.         && modifier != EXPAND_CONST_ADDRESS
  4487.         && modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  4488.         || GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  4489.         /* If the field isn't aligned enough to fetch as a memref,
  4490.            fetch it as a bit field.  */
  4491.         || (STRICT_ALIGNMENT
  4492.         && TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode))
  4493.         || (STRICT_ALIGNMENT && bitpos % GET_MODE_ALIGNMENT (mode) != 0))
  4494.       {
  4495.         enum machine_mode ext_mode = mode;
  4496.  
  4497.         if (ext_mode == BLKmode)
  4498.           ext_mode = mode_for_size (bitsize, MODE_INT, 1);
  4499.  
  4500.         if (ext_mode == BLKmode)
  4501.           abort ();
  4502.  
  4503.         op0 = extract_bit_field (validize_mem (op0), bitsize, bitpos,
  4504.                      unsignedp, target, ext_mode, ext_mode,
  4505.                      alignment,
  4506.                      int_size_in_bytes (TREE_TYPE (tem)));
  4507.         if (mode == BLKmode)
  4508.           {
  4509.         rtx new = assign_stack_temp (ext_mode,
  4510.                          bitsize / BITS_PER_UNIT, 0);
  4511.  
  4512.         emit_move_insn (new, op0);
  4513.         op0 = copy_rtx (new);
  4514.         PUT_MODE (op0, BLKmode);
  4515.         MEM_IN_STRUCT_P (op0) = 1;
  4516.           }
  4517.  
  4518.         return op0;
  4519.       }
  4520.  
  4521.     /* Get a reference to just this component.  */
  4522.     if (modifier == EXPAND_CONST_ADDRESS
  4523.         || modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  4524.       op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
  4525.                             (bitpos / BITS_PER_UNIT)));
  4526.     else
  4527.       op0 = change_address (op0, mode1,
  4528.                 plus_constant (XEXP (op0, 0),
  4529.                            (bitpos / BITS_PER_UNIT)));
  4530.     MEM_IN_STRUCT_P (op0) = 1;
  4531.     MEM_VOLATILE_P (op0) |= volatilep;
  4532.     if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
  4533.       return op0;
  4534.     if (target == 0)
  4535.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4536.     convert_move (target, op0, unsignedp);
  4537.     return target;
  4538.       }
  4539.  
  4540.     case OFFSET_REF:
  4541.       {
  4542.     tree base = build1 (ADDR_EXPR, type, TREE_OPERAND (exp, 0));
  4543.     tree addr = build (PLUS_EXPR, type, base, TREE_OPERAND (exp, 1));
  4544.     op0 = expand_expr (addr, NULL_RTX, VOIDmode, EXPAND_SUM);
  4545.     temp = gen_rtx (MEM, mode, memory_address (mode, op0));
  4546.     MEM_IN_STRUCT_P (temp) = 1;
  4547.     MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp);
  4548. #if 0 /* It is incorrect to set RTX_UNCHANGING_P here, because the fact that
  4549.      a location is accessed through a pointer to const does not mean
  4550.      that the value there can never change.  */
  4551.     RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
  4552. #endif
  4553.     return temp;
  4554.       }
  4555.  
  4556.       /* Intended for a reference to a buffer of a file-object in Pascal.
  4557.      But it's not certain that a special tree code will really be
  4558.      necessary for these.  INDIRECT_REF might work for them.  */
  4559.     case BUFFER_REF:
  4560.       abort ();
  4561.  
  4562.     case IN_EXPR:
  4563.       {
  4564.     /* Pascal set IN expression.
  4565.  
  4566.        Algorithm:
  4567.            rlo       = set_low - (set_low%bits_per_word);
  4568.            the_word  = set [ (index - rlo)/bits_per_word ];
  4569.            bit_index = index % bits_per_word;
  4570.            bitmask   = 1 << bit_index;
  4571.            return !!(the_word & bitmask);  */
  4572.  
  4573.     tree set = TREE_OPERAND (exp, 0);
  4574.     tree index = TREE_OPERAND (exp, 1);
  4575.     int iunsignedp = TREE_UNSIGNED (TREE_TYPE (index));
  4576.     tree set_type = TREE_TYPE (set);
  4577.     tree set_low_bound = TYPE_MIN_VALUE (TYPE_DOMAIN (set_type));
  4578.     tree set_high_bound = TYPE_MAX_VALUE (TYPE_DOMAIN (set_type));
  4579.     rtx index_val = expand_expr (index, 0, VOIDmode, 0);
  4580.     rtx lo_r = expand_expr (set_low_bound, 0, VOIDmode, 0);
  4581.     rtx hi_r = expand_expr (set_high_bound, 0, VOIDmode, 0);
  4582.     rtx setval = expand_expr (set, 0, VOIDmode, 0);
  4583.     rtx setaddr = XEXP (setval, 0);
  4584.     enum machine_mode index_mode = TYPE_MODE (TREE_TYPE (index));
  4585.     rtx rlow;
  4586.     rtx diff, quo, rem, addr, bit, result;
  4587.  
  4588.     preexpand_calls (exp);
  4589.  
  4590.     /* If domain is empty, answer is no.  Likewise if index is constant
  4591.        and out of bounds.  */
  4592.     if ((TREE_CODE (set_high_bound) == INTEGER_CST
  4593.          && TREE_CODE (set_low_bound) == INTEGER_CST
  4594.          && tree_int_cst_lt (set_high_bound, set_low_bound)
  4595.          || (TREE_CODE (index) == INTEGER_CST
  4596.          && TREE_CODE (set_low_bound) == INTEGER_CST
  4597.          && tree_int_cst_lt (index, set_low_bound))
  4598.          || (TREE_CODE (set_high_bound) == INTEGER_CST
  4599.          && TREE_CODE (index) == INTEGER_CST
  4600.          && tree_int_cst_lt (set_high_bound, index))))
  4601.       return const0_rtx;
  4602.  
  4603.     if (target == 0)
  4604.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4605.  
  4606.     /* If we get here, we have to generate the code for both cases
  4607.        (in range and out of range).  */
  4608.  
  4609.     op0 = gen_label_rtx ();
  4610.     op1 = gen_label_rtx ();
  4611.  
  4612.     if (! (GET_CODE (index_val) == CONST_INT
  4613.            && GET_CODE (lo_r) == CONST_INT))
  4614.       {
  4615.         emit_cmp_insn (index_val, lo_r, LT, NULL_RTX,
  4616.                GET_MODE (index_val), iunsignedp, 0);
  4617.         emit_jump_insn (gen_blt (op1));
  4618.       }
  4619.  
  4620.     if (! (GET_CODE (index_val) == CONST_INT
  4621.            && GET_CODE (hi_r) == CONST_INT))
  4622.       {
  4623.         emit_cmp_insn (index_val, hi_r, GT, NULL_RTX,
  4624.                GET_MODE (index_val), iunsignedp, 0);
  4625.         emit_jump_insn (gen_bgt (op1));
  4626.       }
  4627.  
  4628.     /* Calculate the element number of bit zero in the first word
  4629.        of the set.  */
  4630.     if (GET_CODE (lo_r) == CONST_INT)
  4631.       rlow = GEN_INT (INTVAL (lo_r)
  4632.               & ~ ((HOST_WIDE_INT) 1 << BITS_PER_UNIT));
  4633.     else
  4634.       rlow = expand_binop (index_mode, and_optab, lo_r,
  4635.                    GEN_INT (~((HOST_WIDE_INT) 1 << BITS_PER_UNIT)),
  4636.                    NULL_RTX, iunsignedp, OPTAB_LIB_WIDEN);
  4637.  
  4638.     diff = expand_binop (index_mode, sub_optab, index_val, rlow,
  4639.                  NULL_RTX, iunsignedp, OPTAB_LIB_WIDEN);
  4640.  
  4641.     quo = expand_divmod (0, TRUNC_DIV_EXPR, index_mode, diff,
  4642.                  GEN_INT (BITS_PER_UNIT), NULL_RTX, iunsignedp);
  4643.     rem = expand_divmod (1, TRUNC_MOD_EXPR, index_mode, index_val,
  4644.                  GEN_INT (BITS_PER_UNIT), NULL_RTX, iunsignedp);
  4645.  
  4646.     addr = memory_address (byte_mode,
  4647.                    expand_binop (index_mode, add_optab, diff,
  4648.                          setaddr, NULL_RTX, iunsignedp,
  4649.                          OPTAB_LIB_WIDEN));
  4650.  
  4651.     /* Extract the bit we want to examine */
  4652.     bit = expand_shift (RSHIFT_EXPR, byte_mode,
  4653.                 gen_rtx (MEM, byte_mode, addr),
  4654.                 make_tree (TREE_TYPE (index), rem),
  4655.                 NULL_RTX, 1);
  4656.     result = expand_binop (byte_mode, and_optab, bit, const1_rtx,
  4657.                    GET_MODE (target) == byte_mode ? target : 0,
  4658.                    1, OPTAB_LIB_WIDEN);
  4659.  
  4660.     if (result != target)
  4661.       convert_move (target, result, 1);
  4662.  
  4663.     /* Output the code to handle the out-of-range case.  */
  4664.     emit_jump (op0);
  4665.     emit_label (op1);
  4666.     emit_move_insn (target, const0_rtx);
  4667.     emit_label (op0);
  4668.     return target;
  4669.       }
  4670.  
  4671.     case WITH_CLEANUP_EXPR:
  4672.       if (RTL_EXPR_RTL (exp) == 0)
  4673.     {
  4674.       RTL_EXPR_RTL (exp)
  4675.         = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  4676.       cleanups_this_call
  4677.         = tree_cons (NULL_TREE, TREE_OPERAND (exp, 2), cleanups_this_call);
  4678.       /* That's it for this cleanup.  */
  4679.       TREE_OPERAND (exp, 2) = 0;
  4680.       (*interim_eh_hook) (NULL_TREE);
  4681.     }
  4682.       return RTL_EXPR_RTL (exp);
  4683.  
  4684.     case CLEANUP_POINT_EXPR:
  4685.       {
  4686.     extern int temp_slot_level;
  4687.     tree old_cleanups = cleanups_this_call;
  4688.     int old_temp_level = target_temp_slot_level;
  4689.     push_temp_slots ();
  4690.     target_temp_slot_level = temp_slot_level;
  4691.     op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier);
  4692.     expand_cleanups_to (old_cleanups);
  4693.     preserve_temp_slots (op0);
  4694.     free_temp_slots ();
  4695.     pop_temp_slots ();
  4696.     target_temp_slot_level = old_temp_level;
  4697.       }
  4698.       return op0;
  4699.  
  4700.     case CALL_EXPR:
  4701.       /* Check for a built-in function.  */
  4702.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  4703.       && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  4704.           == FUNCTION_DECL)
  4705.       && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  4706.     return expand_builtin (exp, target, subtarget, tmode, ignore);
  4707.  
  4708.       /* If this call was expanded already by preexpand_calls,
  4709.      just return the result we got.  */
  4710.       if (CALL_EXPR_RTL (exp) != 0)
  4711.     return CALL_EXPR_RTL (exp);
  4712.  
  4713.       return expand_call (exp, target, ignore);
  4714.  
  4715.     case NON_LVALUE_EXPR:
  4716.     case NOP_EXPR:
  4717.     case CONVERT_EXPR:
  4718.     case REFERENCE_EXPR:
  4719.       if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  4720.     {
  4721.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode,
  4722.                  modifier);
  4723.  
  4724.       /* If the signedness of the conversion differs and OP0 is
  4725.          a promoted SUBREG, clear that indication since we now
  4726.          have to do the proper extension.  */
  4727.       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))) != unsignedp
  4728.           && GET_CODE (op0) == SUBREG)
  4729.         SUBREG_PROMOTED_VAR_P (op0) = 0;
  4730.  
  4731.       return op0;
  4732.     }
  4733.  
  4734.       if (TREE_CODE (type) == UNION_TYPE)
  4735.     {
  4736.       tree valtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  4737.       if (target == 0)
  4738.         {
  4739.           if (mode == BLKmode)
  4740.         {
  4741.           if (TYPE_SIZE (type) == 0
  4742.               || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  4743.             abort ();
  4744.           target = assign_stack_temp (BLKmode,
  4745.                           (TREE_INT_CST_LOW (TYPE_SIZE (type))
  4746.                            + BITS_PER_UNIT - 1)
  4747.                           / BITS_PER_UNIT, 0);
  4748.         }
  4749.           else
  4750.         target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4751.         }
  4752.  
  4753.       if (GET_CODE (target) == MEM)
  4754.         /* Store data into beginning of memory target.  */
  4755.         store_expr (TREE_OPERAND (exp, 0),
  4756.             change_address (target, TYPE_MODE (valtype), 0), 0);
  4757.  
  4758.       else if (GET_CODE (target) == REG)
  4759.         /* Store this field into a union of the proper type.  */
  4760.         store_field (target, GET_MODE_BITSIZE (TYPE_MODE (valtype)), 0,
  4761.              TYPE_MODE (valtype), TREE_OPERAND (exp, 0),
  4762.              VOIDmode, 0, 1,
  4763.              int_size_in_bytes (TREE_TYPE (TREE_OPERAND (exp, 0))));
  4764.       else
  4765.         abort ();
  4766.  
  4767.       /* Return the entire union.  */
  4768.       return target;
  4769.     }
  4770.  
  4771.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, mode, 0);
  4772.       if (GET_MODE (op0) == mode)
  4773.     return op0;
  4774.  
  4775.       /* If OP0 is a constant, just convert it into the proper mode.  */
  4776.       if (CONSTANT_P (op0))
  4777.     return
  4778.       convert_modes (mode, TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  4779.              op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  4780.  
  4781.       if (modifier == EXPAND_INITIALIZER)
  4782.     return gen_rtx (unsignedp ? ZERO_EXTEND : SIGN_EXTEND, mode, op0);
  4783.  
  4784.       if (flag_force_mem && GET_CODE (op0) == MEM)
  4785.     op0 = copy_to_reg (op0);
  4786.  
  4787.       if (target == 0)
  4788.     return
  4789.       convert_to_mode (mode, op0,
  4790.                TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  4791.       else
  4792.     convert_move (target, op0,
  4793.               TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  4794.       return target;
  4795.  
  4796.     case PLUS_EXPR:
  4797.       /* We come here from MINUS_EXPR when the second operand is a constant. */
  4798.     plus_expr:
  4799.       this_optab = add_optab;
  4800.  
  4801.       /* If we are adding a constant, an RTL_EXPR that is sp, fp, or ap, and
  4802.      something else, make sure we add the register to the constant and
  4803.      then to the other thing.  This case can occur during strength
  4804.      reduction and doing it this way will produce better code if the
  4805.      frame pointer or argument pointer is eliminated.
  4806.  
  4807.      fold-const.c will ensure that the constant is always in the inner
  4808.      PLUS_EXPR, so the only case we need to do anything about is if
  4809.      sp, ap, or fp is our second argument, in which case we must swap
  4810.      the innermost first argument and our second argument.  */
  4811.  
  4812.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  4813.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 1)) == INTEGER_CST
  4814.       && TREE_CODE (TREE_OPERAND (exp, 1)) == RTL_EXPR
  4815.       && (RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == frame_pointer_rtx
  4816.           || RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == stack_pointer_rtx
  4817.           || RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == arg_pointer_rtx))
  4818.     {
  4819.       tree t = TREE_OPERAND (exp, 1);
  4820.  
  4821.       TREE_OPERAND (exp, 1) = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  4822.       TREE_OPERAND (TREE_OPERAND (exp, 0), 0) = t;
  4823.     }
  4824.  
  4825.       /* If the result is to be Pmode and we are adding an integer to
  4826.      something, we might be forming a constant.  So try to use
  4827.      plus_constant.  If it produces a sum and we can't accept it,
  4828.      use force_operand.  This allows P = &ARR[const] to generate
  4829.      efficient code on machines where a SYMBOL_REF is not a valid
  4830.      address.
  4831.  
  4832.      If this is an EXPAND_SUM call, always return the sum.  */
  4833.       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER
  4834.       || mode == Pmode)
  4835.     {
  4836.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
  4837.           && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
  4838.           && TREE_CONSTANT (TREE_OPERAND (exp, 1)))
  4839.         {
  4840.           op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode,
  4841.                  EXPAND_SUM);
  4842.           op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
  4843.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  4844.         op1 = force_operand (op1, target);
  4845.           return op1;
  4846.         }
  4847.  
  4848.       else if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  4849.            && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
  4850.            && TREE_CONSTANT (TREE_OPERAND (exp, 0)))
  4851.         {
  4852.           op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode,
  4853.                  EXPAND_SUM);
  4854.           if (! CONSTANT_P (op0))
  4855.         {
  4856.           op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  4857.                      VOIDmode, modifier);
  4858.           /* Don't go to both_summands if modifier
  4859.              says it's not right to return a PLUS.  */
  4860.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  4861.             goto binop2;
  4862.           goto both_summands;
  4863.         }
  4864.           op0 = plus_constant (op0, TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  4865.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  4866.         op0 = force_operand (op0, target);
  4867.           return op0;
  4868.         }
  4869.     }
  4870.  
  4871.       /* No sense saving up arithmetic to be done
  4872.      if it's all in the wrong mode to form part of an address.
  4873.      And force_operand won't know whether to sign-extend or
  4874.      zero-extend.  */
  4875.       if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  4876.       || mode != Pmode)
  4877.     goto binop;
  4878.  
  4879.       preexpand_calls (exp);
  4880.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  4881.     subtarget = 0;
  4882.  
  4883.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, modifier);
  4884.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, modifier);
  4885.  
  4886.     both_summands:
  4887.       /* Make sure any term that's a sum with a constant comes last.  */
  4888.       if (GET_CODE (op0) == PLUS
  4889.       && CONSTANT_P (XEXP (op0, 1)))
  4890.     {
  4891.       temp = op0;
  4892.       op0 = op1;
  4893.       op1 = temp;
  4894.     }
  4895.       /* If adding to a sum including a constant,
  4896.      associate it to put the constant outside.  */
  4897.       if (GET_CODE (op1) == PLUS
  4898.       && CONSTANT_P (XEXP (op1, 1)))
  4899.     {
  4900.       rtx constant_term = const0_rtx;
  4901.  
  4902.       temp = simplify_binary_operation (PLUS, mode, XEXP (op1, 0), op0);
  4903.       if (temp != 0)
  4904.         op0 = temp;
  4905.       /* Ensure that MULT comes first if there is one.  */
  4906.       else if (GET_CODE (op0) == MULT)
  4907.         op0 = gen_rtx (PLUS, mode, op0, XEXP (op1, 0));
  4908.       else
  4909.         op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
  4910.  
  4911.       /* Let's also eliminate constants from op0 if possible.  */
  4912.       op0 = eliminate_constant_term (op0, &constant_term);
  4913.  
  4914.       /* CONSTANT_TERM and XEXP (op1, 1) are known to be constant, so
  4915.          their sum should be a constant.  Form it into OP1, since the 
  4916.          result we want will then be OP0 + OP1.  */
  4917.  
  4918.       temp = simplify_binary_operation (PLUS, mode, constant_term,
  4919.                         XEXP (op1, 1));
  4920.       if (temp != 0)
  4921.         op1 = temp;
  4922.       else
  4923.         op1 = gen_rtx (PLUS, mode, constant_term, XEXP (op1, 1));
  4924.     }
  4925.  
  4926.       /* Put a constant term last and put a multiplication first.  */
  4927.       if (CONSTANT_P (op0) || GET_CODE (op1) == MULT)
  4928.     temp = op1, op1 = op0, op0 = temp;
  4929.  
  4930.       temp = simplify_binary_operation (PLUS, mode, op0, op1);
  4931.       return temp ? temp : gen_rtx (PLUS, mode, op0, op1);
  4932.  
  4933.     case MINUS_EXPR:
  4934.       /* For initializers, we are allowed to return a MINUS of two
  4935.      symbolic constants.  Here we handle all cases when both operands
  4936.      are constant.  */
  4937.       /* Handle difference of two symbolic constants,
  4938.      for the sake of an initializer.  */
  4939.       if ((modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  4940.       && really_constant_p (TREE_OPERAND (exp, 0))
  4941.       && really_constant_p (TREE_OPERAND (exp, 1)))
  4942.     {
  4943.       rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX,
  4944.                  VOIDmode, modifier);
  4945.       rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  4946.                  VOIDmode, modifier);
  4947.  
  4948.       /* If one operand is a CONST_INT, put it last.  */
  4949.       if (GET_CODE (op0) == CONST_INT)
  4950.         temp = op0, op0 = op1, op1 = temp;
  4951.  
  4952.       /* If the last operand is a CONST_INT, use plus_constant of
  4953.          the negated constant.  Else make the MINUS.  */
  4954.       if (GET_CODE (op1) == CONST_INT)
  4955.         return plus_constant (op0, - INTVAL (op1));
  4956.       else
  4957.         return gen_rtx (MINUS, mode, op0, op1);
  4958.     }
  4959.       /* Convert A - const to A + (-const).  */
  4960.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  4961.     {
  4962.       exp = build (PLUS_EXPR, type, TREE_OPERAND (exp, 0),
  4963.                fold (build1 (NEGATE_EXPR, type,
  4964.                      TREE_OPERAND (exp, 1))));
  4965.       goto plus_expr;
  4966.     }
  4967.       this_optab = sub_optab;
  4968.       goto binop;
  4969.  
  4970.     case MULT_EXPR:
  4971.       preexpand_calls (exp);
  4972.       /* If first operand is constant, swap them.
  4973.      Thus the following special case checks need only
  4974.      check the second operand.  */
  4975.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
  4976.     {
  4977.       register tree t1 = TREE_OPERAND (exp, 0);
  4978.       TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
  4979.       TREE_OPERAND (exp, 1) = t1;
  4980.     }
  4981.  
  4982.       /* Attempt to return something suitable for generating an
  4983.      indexed address, for machines that support that.  */
  4984.  
  4985.       if (modifier == EXPAND_SUM && mode == Pmode
  4986.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  4987.       && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
  4988.     {
  4989.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  4990.  
  4991.       /* Apply distributive law if OP0 is x+c.  */
  4992.       if (GET_CODE (op0) == PLUS
  4993.           && GET_CODE (XEXP (op0, 1)) == CONST_INT)
  4994.         return gen_rtx (PLUS, mode,
  4995.                 gen_rtx (MULT, mode, XEXP (op0, 0),
  4996.                      GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
  4997.                 GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  4998.                      * INTVAL (XEXP (op0, 1))));
  4999.  
  5000.       if (GET_CODE (op0) != REG)
  5001.         op0 = force_operand (op0, NULL_RTX);
  5002.       if (GET_CODE (op0) != REG)
  5003.         op0 = copy_to_mode_reg (mode, op0);
  5004.  
  5005.       return gen_rtx (MULT, mode, op0,
  5006.               GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
  5007.     }
  5008.  
  5009.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5010.     subtarget = 0;
  5011.  
  5012.       /* Check for multiplying things that have been extended
  5013.      from a narrower type.  If this machine supports multiplying
  5014.      in that narrower type with a result in the desired type,
  5015.      do it that way, and avoid the explicit type-conversion.  */
  5016.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
  5017.       && TREE_CODE (type) == INTEGER_TYPE
  5018.       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5019.           < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5020.       && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5021.            && int_fits_type_p (TREE_OPERAND (exp, 1),
  5022.                    TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5023.            /* Don't use a widening multiply if a shift will do.  */
  5024.            && ((GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))))
  5025.             > HOST_BITS_PER_WIDE_INT)
  5026.            || exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0))
  5027.           ||
  5028.           (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
  5029.            && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  5030.            ==
  5031.            TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
  5032.            /* If both operands are extended, they must either both
  5033.           be zero-extended or both be sign-extended.  */
  5034.            && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  5035.            ==
  5036.            TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
  5037.     {
  5038.       enum machine_mode innermode
  5039.         = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
  5040.       this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5041.             ? umul_widen_optab : smul_widen_optab);
  5042.       if (mode == GET_MODE_WIDER_MODE (innermode)
  5043.           && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  5044.         {
  5045.           op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5046.                  NULL_RTX, VOIDmode, 0);
  5047.           if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  5048.         op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5049.                    VOIDmode, 0);
  5050.           else
  5051.         op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
  5052.                    NULL_RTX, VOIDmode, 0);
  5053.           goto binop2;
  5054.         }
  5055.     }
  5056.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5057.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5058.       return expand_mult (mode, op0, op1, target, unsignedp);
  5059.  
  5060.     case TRUNC_DIV_EXPR:
  5061.     case FLOOR_DIV_EXPR:
  5062.     case CEIL_DIV_EXPR:
  5063.     case ROUND_DIV_EXPR:
  5064.     case EXACT_DIV_EXPR:
  5065.       preexpand_calls (exp);
  5066.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5067.     subtarget = 0;
  5068.       /* Possible optimization: compute the dividend with EXPAND_SUM
  5069.      then if the divisor is constant can optimize the case
  5070.      where some terms of the dividend have coeffs divisible by it.  */
  5071.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5072.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5073.       return expand_divmod (0, code, mode, op0, op1, target, unsignedp);
  5074.  
  5075.     case RDIV_EXPR:
  5076.       this_optab = flodiv_optab;
  5077.       goto binop;
  5078.  
  5079.     case TRUNC_MOD_EXPR:
  5080.     case FLOOR_MOD_EXPR:
  5081.     case CEIL_MOD_EXPR:
  5082.     case ROUND_MOD_EXPR:
  5083.       preexpand_calls (exp);
  5084.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5085.     subtarget = 0;
  5086.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5087.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5088.       return expand_divmod (1, code, mode, op0, op1, target, unsignedp);
  5089.  
  5090.     case FIX_ROUND_EXPR:
  5091.     case FIX_FLOOR_EXPR:
  5092.     case FIX_CEIL_EXPR:
  5093.       abort ();            /* Not used for C.  */
  5094.  
  5095.     case FIX_TRUNC_EXPR:
  5096.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  5097.       if (target == 0)
  5098.     target = gen_reg_rtx (mode);
  5099.       expand_fix (target, op0, unsignedp);
  5100.       return target;
  5101.  
  5102.     case FLOAT_EXPR:
  5103.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  5104.       if (target == 0)
  5105.     target = gen_reg_rtx (mode);
  5106.       /* expand_float can't figure out what to do if FROM has VOIDmode.
  5107.      So give it the correct mode.  With -O, cse will optimize this.  */
  5108.       if (GET_MODE (op0) == VOIDmode)
  5109.     op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  5110.                 op0);
  5111.       expand_float (target, op0,
  5112.             TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5113.       return target;
  5114.  
  5115.     case NEGATE_EXPR:
  5116.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5117.       temp = expand_unop (mode, neg_optab, op0, target, 0);
  5118.       if (temp == 0)
  5119.     abort ();
  5120.       return temp;
  5121.  
  5122.     case ABS_EXPR:
  5123.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5124.  
  5125.       /* Handle complex values specially.  */
  5126.       if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
  5127.       || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
  5128.     return expand_complex_abs (mode, op0, target, unsignedp);
  5129.  
  5130.       /* Unsigned abs is simply the operand.  Testing here means we don't
  5131.      risk generating incorrect code below.  */
  5132.       if (TREE_UNSIGNED (type))
  5133.     return op0;
  5134.  
  5135.       /* First try to do it with a special abs instruction.  */
  5136.       temp = expand_unop (mode, abs_optab, op0, target, 0);
  5137.       if (temp != 0)
  5138.     return temp;
  5139.  
  5140.       /* If this machine has expensive jumps, we can do integer absolute
  5141.      value of X as (((signed) x >> (W-1)) ^ x) - ((signed) x >> (W-1)),
  5142.      where W is the width of MODE.  */
  5143.  
  5144.       if (GET_MODE_CLASS (mode) == MODE_INT && BRANCH_COST >= 2)
  5145.     {
  5146.       rtx extended = expand_shift (RSHIFT_EXPR, mode, op0,
  5147.                        size_int (GET_MODE_BITSIZE (mode) - 1),
  5148.                        NULL_RTX, 0);
  5149.  
  5150.       temp = expand_binop (mode, xor_optab, extended, op0, target, 0,
  5151.                    OPTAB_LIB_WIDEN);
  5152.       if (temp != 0)
  5153.         temp = expand_binop (mode, sub_optab, temp, extended, target, 0,
  5154.                  OPTAB_LIB_WIDEN);
  5155.  
  5156.       if (temp != 0)
  5157.         return temp;
  5158.     }
  5159.  
  5160.       /* If that does not win, use conditional jump and negate.  */
  5161.       target = original_target;
  5162.       op1 = gen_label_rtx ();
  5163.       if (target == 0 || ! safe_from_p (target, TREE_OPERAND (exp, 0))
  5164.       || GET_MODE (target) != mode
  5165.       || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  5166.       || (GET_CODE (target) == REG
  5167.           && REGNO (target) < FIRST_PSEUDO_REGISTER))
  5168.     target = gen_reg_rtx (mode);
  5169.  
  5170.       emit_move_insn (target, op0);
  5171.       NO_DEFER_POP;
  5172.  
  5173.       /* If this mode is an integer too wide to compare properly,
  5174.      compare word by word.  Rely on CSE to optimize constant cases.  */
  5175.       if (GET_MODE_CLASS (mode) == MODE_INT && ! can_compare_p (mode))
  5176.     do_jump_by_parts_greater_rtx (mode, 0, target, const0_rtx, 
  5177.                       NULL_RTX, op1);
  5178.       else
  5179.     {
  5180.       temp = compare_from_rtx (target, CONST0_RTX (mode), GE, 0, mode,
  5181.                    NULL_RTX, 0);
  5182.       if (temp == const1_rtx)
  5183.         return target;
  5184.       else if (temp != const0_rtx)
  5185.         {
  5186.           if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
  5187.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op1));
  5188.           else
  5189.         abort ();
  5190.         }
  5191.     }
  5192.  
  5193.       op0 = expand_unop (mode, neg_optab, target, target, 0);
  5194.       if (op0 != target)
  5195.     emit_move_insn (target, op0);
  5196.       emit_label (op1);
  5197.       OK_DEFER_POP;
  5198.       return target;
  5199.  
  5200.     case MAX_EXPR:
  5201.     case MIN_EXPR:
  5202.       target = original_target;
  5203.       if (target == 0 || ! safe_from_p (target, TREE_OPERAND (exp, 1))
  5204.       || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  5205.       || GET_MODE (target) != mode
  5206.       || (GET_CODE (target) == REG
  5207.           && REGNO (target) < FIRST_PSEUDO_REGISTER))
  5208.     target = gen_reg_rtx (mode);
  5209.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5210.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  5211.  
  5212.       /* First try to do it with a special MIN or MAX instruction.
  5213.      If that does not win, use a conditional jump to select the proper
  5214.      value.  */
  5215.       this_optab = (TREE_UNSIGNED (type)
  5216.             ? (code == MIN_EXPR ? umin_optab : umax_optab)
  5217.             : (code == MIN_EXPR ? smin_optab : smax_optab));
  5218.  
  5219.       temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp,
  5220.                OPTAB_WIDEN);
  5221.       if (temp != 0)
  5222.     return temp;
  5223.  
  5224.       if (target != op0)
  5225.     emit_move_insn (target, op0);
  5226.  
  5227.       op0 = gen_label_rtx ();
  5228.  
  5229.       /* If this mode is an integer too wide to compare properly,
  5230.      compare word by word.  Rely on cse to optimize constant cases.  */
  5231.       if (GET_MODE_CLASS (mode) == MODE_INT && !can_compare_p (mode))
  5232.     {
  5233.       if (code == MAX_EXPR)
  5234.         do_jump_by_parts_greater_rtx (mode, TREE_UNSIGNED (type),
  5235.                       target, op1, NULL_RTX, op0);
  5236.       else
  5237.         do_jump_by_parts_greater_rtx (mode, TREE_UNSIGNED (type),
  5238.                       op1, target, NULL_RTX, op0);
  5239.       emit_move_insn (target, op1);
  5240.     }
  5241.       else
  5242.     {
  5243.       if (code == MAX_EXPR)
  5244.         temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  5245.             ? compare_from_rtx (target, op1, GEU, 1, mode, NULL_RTX, 0)
  5246.             : compare_from_rtx (target, op1, GE, 0, mode, NULL_RTX, 0));
  5247.       else
  5248.         temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  5249.             ? compare_from_rtx (target, op1, LEU, 1, mode, NULL_RTX, 0)
  5250.             : compare_from_rtx (target, op1, LE, 0, mode, NULL_RTX, 0));
  5251.       if (temp == const0_rtx)
  5252.         emit_move_insn (target, op1);
  5253.       else if (temp != const_true_rtx)
  5254.         {
  5255.           if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
  5256.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
  5257.           else
  5258.         abort ();
  5259.           emit_move_insn (target, op1);
  5260.         }
  5261.     }
  5262.       emit_label (op0);
  5263.       return target;
  5264.  
  5265.     case BIT_NOT_EXPR:
  5266.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5267.       temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
  5268.       if (temp == 0)
  5269.     abort ();
  5270.       return temp;
  5271.  
  5272.     case FFS_EXPR:
  5273.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5274.       temp = expand_unop (mode, ffs_optab, op0, target, 1);
  5275.       if (temp == 0)
  5276.     abort ();
  5277.       return temp;
  5278.  
  5279.       /* ??? Can optimize bitwise operations with one arg constant.
  5280.      Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b)
  5281.      and (a bitwise1 b) bitwise2 b (etc)
  5282.      but that is probably not worth while.  */
  5283.  
  5284.       /* BIT_AND_EXPR is for bitwise anding.  TRUTH_AND_EXPR is for anding two
  5285.      boolean values when we want in all cases to compute both of them.  In
  5286.      general it is fastest to do TRUTH_AND_EXPR by computing both operands
  5287.      as actual zero-or-1 values and then bitwise anding.  In cases where
  5288.      there cannot be any side effects, better code would be made by
  5289.      treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR; but the question is
  5290.      how to recognize those cases.  */
  5291.  
  5292.     case TRUTH_AND_EXPR:
  5293.     case BIT_AND_EXPR:
  5294.       this_optab = and_optab;
  5295.       goto binop;
  5296.  
  5297.     case TRUTH_OR_EXPR:
  5298.     case BIT_IOR_EXPR:
  5299.       this_optab = ior_optab;
  5300.       goto binop;
  5301.  
  5302.     case TRUTH_XOR_EXPR:
  5303.     case BIT_XOR_EXPR:
  5304.       this_optab = xor_optab;
  5305.       goto binop;
  5306.  
  5307.     case LSHIFT_EXPR:
  5308.     case RSHIFT_EXPR:
  5309.     case LROTATE_EXPR:
  5310.     case RROTATE_EXPR:
  5311.       preexpand_calls (exp);
  5312.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5313.     subtarget = 0;
  5314.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5315.       return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
  5316.                unsignedp);
  5317.  
  5318.       /* Could determine the answer when only additive constants differ.  Also,
  5319.      the addition of one can be handled by changing the condition.  */
  5320.     case LT_EXPR:
  5321.     case LE_EXPR:
  5322.     case GT_EXPR:
  5323.     case GE_EXPR:
  5324.     case EQ_EXPR:
  5325.     case NE_EXPR:
  5326.       preexpand_calls (exp);
  5327.       temp = do_store_flag (exp, target, tmode != VOIDmode ? tmode : mode, 0);
  5328.       if (temp != 0)
  5329.     return temp;
  5330.  
  5331.       /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
  5332.       if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
  5333.       && original_target
  5334.       && GET_CODE (original_target) == REG
  5335.       && (GET_MODE (original_target)
  5336.           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5337.     {
  5338.       temp = expand_expr (TREE_OPERAND (exp, 0), original_target,
  5339.                   VOIDmode, 0);
  5340.  
  5341.       if (temp != original_target)
  5342.         temp = copy_to_reg (temp);
  5343.  
  5344.       op1 = gen_label_rtx ();
  5345.       emit_cmp_insn (temp, const0_rtx, EQ, NULL_RTX,
  5346.              GET_MODE (temp), unsignedp, 0);
  5347.       emit_jump_insn (gen_beq (op1));
  5348.       emit_move_insn (temp, const1_rtx);
  5349.       emit_label (op1);
  5350.       return temp;
  5351.     }
  5352.  
  5353.       /* If no set-flag instruction, must generate a conditional
  5354.      store into a temporary variable.  Drop through
  5355.      and handle this like && and ||.  */
  5356.  
  5357.     case TRUTH_ANDIF_EXPR:
  5358.     case TRUTH_ORIF_EXPR:
  5359.       if (! ignore
  5360.       && (target == 0 || ! safe_from_p (target, exp)
  5361.           /* Make sure we don't have a hard reg (such as function's return
  5362.          value) live across basic blocks, if not optimizing.  */
  5363.           || (!optimize && GET_CODE (target) == REG
  5364.           && REGNO (target) < FIRST_PSEUDO_REGISTER)))
  5365.     target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5366.  
  5367.       if (target)
  5368.     emit_clr_insn (target);
  5369.  
  5370.       op1 = gen_label_rtx ();
  5371.       jumpifnot (exp, op1);
  5372.  
  5373.       if (target)
  5374.     emit_0_to_1_insn (target);
  5375.  
  5376.       emit_label (op1);
  5377.       return ignore ? const0_rtx : target;
  5378.  
  5379.     case TRUTH_NOT_EXPR:
  5380.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  5381.       /* The parser is careful to generate TRUTH_NOT_EXPR
  5382.      only with operands that are always zero or one.  */
  5383.       temp = expand_binop (mode, xor_optab, op0, const1_rtx,
  5384.                target, 1, OPTAB_LIB_WIDEN);
  5385.       if (temp == 0)
  5386.     abort ();
  5387.       return temp;
  5388.  
  5389.     case COMPOUND_EXPR:
  5390.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  5391.       emit_queue ();
  5392.       return expand_expr (TREE_OPERAND (exp, 1),
  5393.               (ignore ? const0_rtx : target),
  5394.               VOIDmode, 0);
  5395.  
  5396.     case COND_EXPR:
  5397.       {
  5398.     rtx flag = NULL_RTX;
  5399.     tree left_cleanups = NULL_TREE;
  5400.     tree right_cleanups = NULL_TREE;
  5401.  
  5402.     /* Used to save a pointer to the place to put the setting of
  5403.        the flag that indicates if this side of the conditional was
  5404.        taken.  We backpatch the code, if we find out later that we
  5405.        have any conditional cleanups that need to be performed. */
  5406.     rtx dest_right_flag = NULL_RTX;
  5407.     rtx dest_left_flag = NULL_RTX;
  5408.  
  5409.     /* Note that COND_EXPRs whose type is a structure or union
  5410.        are required to be constructed to contain assignments of
  5411.        a temporary variable, so that we can evaluate them here
  5412.        for side effect only.  If type is void, we must do likewise.  */
  5413.  
  5414.     /* If an arm of the branch requires a cleanup,
  5415.        only that cleanup is performed.  */
  5416.  
  5417.     tree singleton = 0;
  5418.     tree binary_op = 0, unary_op = 0;
  5419.     tree old_cleanups = cleanups_this_call;
  5420.  
  5421.     /* If this is (A ? 1 : 0) and A is a condition, just evaluate it and
  5422.        convert it to our mode, if necessary.  */
  5423.     if (integer_onep (TREE_OPERAND (exp, 1))
  5424.         && integer_zerop (TREE_OPERAND (exp, 2))
  5425.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  5426.       {
  5427.         if (ignore)
  5428.           {
  5429.         expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
  5430.                  modifier);
  5431.         return const0_rtx;
  5432.           }
  5433.  
  5434.         op0 = expand_expr (TREE_OPERAND (exp, 0), target, mode, modifier);
  5435.         if (GET_MODE (op0) == mode)
  5436.           return op0;
  5437.  
  5438.         if (target == 0)
  5439.           target = gen_reg_rtx (mode);
  5440.         convert_move (target, op0, unsignedp);
  5441.         return target;
  5442.       }
  5443.  
  5444.     /* If we are not to produce a result, we have no target.  Otherwise,
  5445.        if a target was specified use it; it will not be used as an
  5446.        intermediate target unless it is safe.  If no target, use a 
  5447.        temporary.  */
  5448.  
  5449.     if (ignore)
  5450.       temp = 0;
  5451.     else if (original_target
  5452.          && safe_from_p (original_target, TREE_OPERAND (exp, 0))
  5453.          && GET_MODE (original_target) == mode)
  5454.       temp = original_target;
  5455.     else if (mode == BLKmode)
  5456.       {
  5457.         if (TYPE_SIZE (type) == 0
  5458.         || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  5459.           abort ();
  5460.  
  5461.         temp = assign_stack_temp (BLKmode,
  5462.                       (TREE_INT_CST_LOW (TYPE_SIZE (type))
  5463.                        + BITS_PER_UNIT - 1)
  5464.                       / BITS_PER_UNIT, 0);
  5465.         MEM_IN_STRUCT_P (temp) = AGGREGATE_TYPE_P (type);
  5466.       }
  5467.     else
  5468.       temp = gen_reg_rtx (mode);
  5469.  
  5470.     /* Check for X ? A + B : A.  If we have this, we can copy
  5471.        A to the output and conditionally add B.  Similarly for unary
  5472.        operations.  Don't do this if X has side-effects because
  5473.        those side effects might affect A or B and the "?" operation is
  5474.        a sequence point in ANSI.  (We test for side effects later.)  */
  5475.  
  5476.     if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '2'
  5477.         && operand_equal_p (TREE_OPERAND (exp, 2),
  5478.                 TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  5479.       singleton = TREE_OPERAND (exp, 2), binary_op = TREE_OPERAND (exp, 1);
  5480.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '2'
  5481.          && operand_equal_p (TREE_OPERAND (exp, 1),
  5482.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  5483.       singleton = TREE_OPERAND (exp, 1), binary_op = TREE_OPERAND (exp, 2);
  5484.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '1'
  5485.          && operand_equal_p (TREE_OPERAND (exp, 2),
  5486.                      TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  5487.       singleton = TREE_OPERAND (exp, 2), unary_op = TREE_OPERAND (exp, 1);
  5488.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '1'
  5489.          && operand_equal_p (TREE_OPERAND (exp, 1),
  5490.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  5491.       singleton = TREE_OPERAND (exp, 1), unary_op = TREE_OPERAND (exp, 2);
  5492.  
  5493.     /* If we had X ? A + 1 : A and we can do the test of X as a store-flag
  5494.        operation, do this as A + (X != 0).  Similarly for other simple
  5495.        binary operators.  */
  5496.     if (temp && singleton && binary_op
  5497.         && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5498.         && (TREE_CODE (binary_op) == PLUS_EXPR
  5499.         || TREE_CODE (binary_op) == MINUS_EXPR
  5500.         || TREE_CODE (binary_op) == BIT_IOR_EXPR
  5501.         || TREE_CODE (binary_op) == BIT_XOR_EXPR
  5502.         || TREE_CODE (binary_op) == BIT_AND_EXPR)
  5503.         && integer_onep (TREE_OPERAND (binary_op, 1))
  5504.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  5505.       {
  5506.         rtx result;
  5507.         optab boptab = (TREE_CODE (binary_op) == PLUS_EXPR ? add_optab
  5508.                 : TREE_CODE (binary_op) == MINUS_EXPR ? sub_optab
  5509.                 : TREE_CODE (binary_op) == BIT_IOR_EXPR ? ior_optab
  5510.                 : TREE_CODE (binary_op) == BIT_XOR_EXPR ? xor_optab
  5511.                 : and_optab);
  5512.  
  5513.         /* If we had X ? A : A + 1, do this as A + (X == 0).
  5514.  
  5515.            We have to invert the truth value here and then put it
  5516.            back later if do_store_flag fails.  We cannot simply copy
  5517.            TREE_OPERAND (exp, 0) to another variable and modify that
  5518.            because invert_truthvalue can modify the tree pointed to
  5519.            by its argument.  */
  5520.         if (singleton == TREE_OPERAND (exp, 1))
  5521.           TREE_OPERAND (exp, 0)
  5522.         = invert_truthvalue (TREE_OPERAND (exp, 0));
  5523.  
  5524.         result = do_store_flag (TREE_OPERAND (exp, 0),
  5525.                     (safe_from_p (temp, singleton)
  5526.                      ? temp : NULL_RTX),
  5527.                     mode, BRANCH_COST <= 1);
  5528.  
  5529.         if (result)
  5530.           {
  5531.         op1 = expand_expr (singleton, NULL_RTX, VOIDmode, 0);
  5532.         return expand_binop (mode, boptab, op1, result, temp,
  5533.                      unsignedp, OPTAB_LIB_WIDEN);
  5534.           }
  5535.         else if (singleton == TREE_OPERAND (exp, 1))
  5536.           TREE_OPERAND (exp, 0)
  5537.         = invert_truthvalue (TREE_OPERAND (exp, 0));
  5538.       }
  5539.         
  5540.     NO_DEFER_POP;
  5541.     op0 = gen_label_rtx ();
  5542.  
  5543.     flag = gen_reg_rtx (word_mode);
  5544.     if (singleton && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0)))
  5545.       {
  5546.         if (temp != 0)
  5547.           {
  5548.         /* If the target conflicts with the other operand of the
  5549.            binary op, we can't use it.  Also, we can't use the target
  5550.            if it is a hard register, because evaluating the condition
  5551.            might clobber it.  */
  5552.         if ((binary_op
  5553.              && ! safe_from_p (temp, TREE_OPERAND (binary_op, 1)))
  5554.             || (GET_CODE (temp) == REG
  5555.             && REGNO (temp) < FIRST_PSEUDO_REGISTER))
  5556.           temp = gen_reg_rtx (mode);
  5557.         store_expr (singleton, temp, 0);
  5558.           }
  5559.         else
  5560.           expand_expr (singleton,
  5561.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5562.         dest_left_flag = get_last_insn ();
  5563.         if (singleton == TREE_OPERAND (exp, 1))
  5564.           jumpif (TREE_OPERAND (exp, 0), op0);
  5565.         else
  5566.           jumpifnot (TREE_OPERAND (exp, 0), op0);
  5567.  
  5568.         /* Allows cleanups up to here. */
  5569.         old_cleanups = cleanups_this_call;
  5570.         if (binary_op && temp == 0)
  5571.           /* Just touch the other operand.  */
  5572.           expand_expr (TREE_OPERAND (binary_op, 1),
  5573.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5574.         else if (binary_op)
  5575.           store_expr (build (TREE_CODE (binary_op), type,
  5576.                  make_tree (type, temp),
  5577.                  TREE_OPERAND (binary_op, 1)),
  5578.               temp, 0);
  5579.         else
  5580.           store_expr (build1 (TREE_CODE (unary_op), type,
  5581.                   make_tree (type, temp)),
  5582.               temp, 0);
  5583.         op1 = op0;
  5584.         dest_right_flag = get_last_insn ();
  5585.       }
  5586. #if 0
  5587.     /* This is now done in jump.c and is better done there because it
  5588.        produces shorter register lifetimes.  */
  5589.        
  5590.     /* Check for both possibilities either constants or variables
  5591.        in registers (but not the same as the target!).  If so, can
  5592.        save branches by assigning one, branching, and assigning the
  5593.        other.  */
  5594.     else if (temp && GET_MODE (temp) != BLKmode
  5595.          && (TREE_CONSTANT (TREE_OPERAND (exp, 1))
  5596.              || ((TREE_CODE (TREE_OPERAND (exp, 1)) == PARM_DECL
  5597.               || TREE_CODE (TREE_OPERAND (exp, 1)) == VAR_DECL)
  5598.              && DECL_RTL (TREE_OPERAND (exp, 1))
  5599.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 1))) == REG
  5600.              && DECL_RTL (TREE_OPERAND (exp, 1)) != temp))
  5601.          && (TREE_CONSTANT (TREE_OPERAND (exp, 2))
  5602.              || ((TREE_CODE (TREE_OPERAND (exp, 2)) == PARM_DECL
  5603.               || TREE_CODE (TREE_OPERAND (exp, 2)) == VAR_DECL)
  5604.              && DECL_RTL (TREE_OPERAND (exp, 2))
  5605.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 2))) == REG
  5606.              && DECL_RTL (TREE_OPERAND (exp, 2)) != temp)))
  5607.       {
  5608.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  5609.           temp = gen_reg_rtx (mode);
  5610.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5611.         dest_left_flag = get_last_insn ();
  5612.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  5613.  
  5614.         /* Allows cleanups up to here. */
  5615.         old_cleanups = cleanups_this_call;
  5616.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5617.         op1 = op0;
  5618.         dest_right_flag = get_last_insn ();
  5619.       }
  5620. #endif
  5621.     /* Check for A op 0 ? A : FOO and A op 0 ? FOO : A where OP is any
  5622.        comparison operator.  If we have one of these cases, set the
  5623.        output to A, branch on A (cse will merge these two references),
  5624.        then set the output to FOO.  */
  5625.     else if (temp
  5626.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  5627.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  5628.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5629.                      TREE_OPERAND (exp, 1), 0)
  5630.          && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5631.          && safe_from_p (temp, TREE_OPERAND (exp, 2)))
  5632.       {
  5633.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  5634.           temp = gen_reg_rtx (mode);
  5635.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5636.         dest_left_flag = get_last_insn ();
  5637.         jumpif (TREE_OPERAND (exp, 0), op0);
  5638.  
  5639.         /* Allows cleanups up to here. */
  5640.         old_cleanups = cleanups_this_call;
  5641.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5642.         op1 = op0;
  5643.         dest_right_flag = get_last_insn ();
  5644.       }
  5645.     else if (temp
  5646.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  5647.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  5648.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5649.                      TREE_OPERAND (exp, 2), 0)
  5650.          && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5651.          && safe_from_p (temp, TREE_OPERAND (exp, 1)))
  5652.       {
  5653.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  5654.           temp = gen_reg_rtx (mode);
  5655.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5656.         dest_left_flag = get_last_insn ();
  5657.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  5658.  
  5659.         /* Allows cleanups up to here. */
  5660.         old_cleanups = cleanups_this_call;
  5661.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5662.         op1 = op0;
  5663.         dest_right_flag = get_last_insn ();
  5664.       }
  5665.     else
  5666.       {
  5667.         op1 = gen_label_rtx ();
  5668.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  5669.  
  5670.         /* Allows cleanups up to here. */
  5671.         old_cleanups = cleanups_this_call;
  5672.         if (temp != 0)
  5673.           store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5674.         else
  5675.           expand_expr (TREE_OPERAND (exp, 1),
  5676.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5677.         dest_left_flag = get_last_insn ();
  5678.  
  5679.         /* Handle conditional cleanups, if any. */
  5680.         left_cleanups = defer_cleanups_to (old_cleanups);
  5681.  
  5682.         emit_queue ();
  5683.         emit_jump_insn (gen_jump (op1));
  5684.         emit_barrier ();
  5685.         emit_label (op0);
  5686.         if (temp != 0)
  5687.           store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5688.         else
  5689.           expand_expr (TREE_OPERAND (exp, 2),
  5690.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5691.         dest_right_flag = get_last_insn ();
  5692.       }
  5693.  
  5694.     /* Handle conditional cleanups, if any. */
  5695.     right_cleanups = defer_cleanups_to (old_cleanups);
  5696.  
  5697.     emit_queue ();
  5698.     emit_label (op1);
  5699.     OK_DEFER_POP;
  5700.  
  5701.     /* Add back in, any conditional cleanups. */
  5702.     if (left_cleanups || right_cleanups)
  5703.       {
  5704.         tree new_cleanups;
  5705.         tree cond;
  5706.         rtx last;
  5707.  
  5708.         /* Now that we know that a flag is needed, go back and add in the
  5709.            setting of the flag. */
  5710.  
  5711.         /* Do the left side flag. */
  5712.         last = get_last_insn ();
  5713.         /* Flag left cleanups as needed. */
  5714.         emit_move_insn (flag, const1_rtx);
  5715.         /* ??? deprecated, use sequences instead.  */
  5716.         reorder_insns (NEXT_INSN (last), get_last_insn (), dest_left_flag);
  5717.  
  5718.         /* Do the right side flag. */
  5719.         last = get_last_insn ();
  5720.         /* Flag left cleanups as needed. */
  5721.         emit_move_insn (flag, const0_rtx);
  5722.         /* ??? deprecated, use sequences instead.  */
  5723.         reorder_insns (NEXT_INSN (last), get_last_insn (), dest_right_flag);
  5724.  
  5725.         /* convert flag, which is an rtx, into a tree. */
  5726.         cond = make_node (RTL_EXPR);
  5727.         TREE_TYPE (cond) = integer_type_node;
  5728.         RTL_EXPR_RTL (cond) = flag;
  5729.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  5730.  
  5731.         if (! left_cleanups)
  5732.           left_cleanups = integer_zero_node;
  5733.         if (! right_cleanups)
  5734.           right_cleanups = integer_zero_node;
  5735.         new_cleanups = build (COND_EXPR, void_type_node, cond,
  5736.                   left_cleanups, right_cleanups);
  5737.         new_cleanups = fold (new_cleanups);
  5738.  
  5739.         /* Now add in the conditionalized cleanups. */
  5740.         cleanups_this_call
  5741.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  5742.         (*interim_eh_hook) (NULL_TREE);
  5743.       }
  5744.     return temp;
  5745.       }
  5746.  
  5747.     case TARGET_EXPR:
  5748.       {
  5749.     int need_exception_region = 0;
  5750.     /* Something needs to be initialized, but we didn't know
  5751.        where that thing was when building the tree.  For example,
  5752.        it could be the return value of a function, or a parameter
  5753.        to a function which lays down in the stack, or a temporary
  5754.        variable which must be passed by reference.
  5755.  
  5756.        We guarantee that the expression will either be constructed
  5757.        or copied into our original target.  */
  5758.  
  5759.     tree slot = TREE_OPERAND (exp, 0);
  5760.     tree exp1;
  5761.     rtx temp;
  5762.  
  5763.     if (TREE_CODE (slot) != VAR_DECL)
  5764.       abort ();
  5765.  
  5766.     if (target == 0)
  5767.       {
  5768.         if (DECL_RTL (slot) != 0)
  5769.           {
  5770.         target = DECL_RTL (slot);
  5771.         /* If we have already expanded the slot, so don't do
  5772.            it again.  (mrs)  */
  5773.         if (TREE_OPERAND (exp, 1) == NULL_TREE)
  5774.           return target;
  5775.           }
  5776.         else
  5777.           {
  5778.         target = assign_stack_temp (mode, int_size_in_bytes (type), 2);
  5779.         /* All temp slots at this level must not conflict.  */
  5780.         preserve_temp_slots (target);
  5781.         DECL_RTL (slot) = target;
  5782.  
  5783.         /* Since SLOT is not known to the called function
  5784.            to belong to its stack frame, we must build an explicit
  5785.            cleanup.  This case occurs when we must build up a reference
  5786.            to pass the reference as an argument.  In this case,
  5787.            it is very likely that such a reference need not be
  5788.            built here.  */
  5789.  
  5790.         if (TREE_OPERAND (exp, 2) == 0)
  5791.           TREE_OPERAND (exp, 2) = maybe_build_cleanup (slot);
  5792.         if (TREE_OPERAND (exp, 2))
  5793.           {
  5794.             cleanups_this_call = tree_cons (NULL_TREE,
  5795.                             TREE_OPERAND (exp, 2),
  5796.                             cleanups_this_call);
  5797.             need_exception_region = 1;
  5798.           }
  5799.           }
  5800.       }
  5801.     else
  5802.       {
  5803.         /* This case does occur, when expanding a parameter which
  5804.            needs to be constructed on the stack.  The target
  5805.            is the actual stack address that we want to initialize.
  5806.            The function we call will perform the cleanup in this case.  */
  5807.  
  5808.         /* If we have already assigned it space, use that space,
  5809.            not target that we were passed in, as our target
  5810.            parameter is only a hint.  */
  5811.         if (DECL_RTL (slot) != 0)
  5812.               {
  5813.                 target = DECL_RTL (slot);
  5814.                 /* If we have already expanded the slot, so don't do
  5815.                    it again.  (mrs)  */
  5816.                 if (TREE_OPERAND (exp, 1) == NULL_TREE)
  5817.                   return target;
  5818.           }
  5819.  
  5820.         DECL_RTL (slot) = target;
  5821.       }
  5822.  
  5823.     exp1 = TREE_OPERAND (exp, 1);
  5824.     /* Mark it as expanded.  */
  5825.     TREE_OPERAND (exp, 1) = NULL_TREE;
  5826.  
  5827.     temp = expand_expr (exp1, target, tmode, modifier);
  5828.  
  5829.     if (need_exception_region)
  5830.       (*interim_eh_hook) (NULL_TREE);
  5831.     
  5832.     return temp;
  5833.       }
  5834.  
  5835.     case INIT_EXPR:
  5836.       {
  5837.     tree lhs = TREE_OPERAND (exp, 0);
  5838.     tree rhs = TREE_OPERAND (exp, 1);
  5839.     tree noncopied_parts = 0;
  5840.     tree lhs_type = TREE_TYPE (lhs);
  5841.  
  5842.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  5843.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0 && !fixed_type_p (rhs))
  5844.       noncopied_parts = init_noncopied_parts (stabilize_reference (lhs),
  5845.                           TYPE_NONCOPIED_PARTS (lhs_type));
  5846.     while (noncopied_parts != 0)
  5847.       {
  5848.         expand_assignment (TREE_VALUE (noncopied_parts),
  5849.                    TREE_PURPOSE (noncopied_parts), 0, 0);
  5850.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  5851.       }
  5852.     return temp;
  5853.       }
  5854.  
  5855.     case MODIFY_EXPR:
  5856.       {
  5857.     /* If lhs is complex, expand calls in rhs before computing it.
  5858.        That's so we don't compute a pointer and save it over a call.
  5859.        If lhs is simple, compute it first so we can give it as a
  5860.        target if the rhs is just a call.  This avoids an extra temp and copy
  5861.        and that prevents a partial-subsumption which makes bad code.
  5862.        Actually we could treat component_ref's of vars like vars.  */
  5863.  
  5864.     tree lhs = TREE_OPERAND (exp, 0);
  5865.     tree rhs = TREE_OPERAND (exp, 1);
  5866.     tree noncopied_parts = 0;
  5867.     tree lhs_type = TREE_TYPE (lhs);
  5868.  
  5869.     temp = 0;
  5870.  
  5871.     if (TREE_CODE (lhs) != VAR_DECL
  5872.         && TREE_CODE (lhs) != RESULT_DECL
  5873.         && TREE_CODE (lhs) != PARM_DECL)
  5874.       preexpand_calls (exp);
  5875.  
  5876.     /* Check for |= or &= of a bitfield of size one into another bitfield
  5877.        of size 1.  In this case, (unless we need the result of the
  5878.        assignment) we can do this more efficiently with a
  5879.        test followed by an assignment, if necessary.
  5880.  
  5881.        ??? At this point, we can't get a BIT_FIELD_REF here.  But if
  5882.        things change so we do, this code should be enhanced to
  5883.        support it.  */
  5884.     if (ignore
  5885.         && TREE_CODE (lhs) == COMPONENT_REF
  5886.         && (TREE_CODE (rhs) == BIT_IOR_EXPR
  5887.         || TREE_CODE (rhs) == BIT_AND_EXPR)
  5888.         && TREE_OPERAND (rhs, 0) == lhs
  5889.         && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF
  5890.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) == 1
  5891.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1)
  5892.       {
  5893.         rtx label = gen_label_rtx ();
  5894.  
  5895.         do_jump (TREE_OPERAND (rhs, 1),
  5896.              TREE_CODE (rhs) == BIT_IOR_EXPR ? label : 0,
  5897.              TREE_CODE (rhs) == BIT_AND_EXPR ? label : 0);
  5898.         expand_assignment (lhs, convert (TREE_TYPE (rhs),
  5899.                          (TREE_CODE (rhs) == BIT_IOR_EXPR
  5900.                           ? integer_one_node
  5901.                           : integer_zero_node)),
  5902.                    0, 0);
  5903.         do_pending_stack_adjust ();
  5904.         emit_label (label);
  5905.         return const0_rtx;
  5906.       }
  5907.  
  5908.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0
  5909.         && ! (fixed_type_p (lhs) && fixed_type_p (rhs)))
  5910.       noncopied_parts = save_noncopied_parts (stabilize_reference (lhs),
  5911.                           TYPE_NONCOPIED_PARTS (lhs_type));
  5912.  
  5913.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  5914.     while (noncopied_parts != 0)
  5915.       {
  5916.         expand_assignment (TREE_PURPOSE (noncopied_parts),
  5917.                    TREE_VALUE (noncopied_parts), 0, 0);
  5918.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  5919.       }
  5920.     return temp;
  5921.       }
  5922.  
  5923.     case PREINCREMENT_EXPR:
  5924.     case PREDECREMENT_EXPR:
  5925.       return expand_increment (exp, 0);
  5926.  
  5927.     case POSTINCREMENT_EXPR:
  5928.     case POSTDECREMENT_EXPR:
  5929.       /* Faster to treat as pre-increment if result is not used.  */
  5930.       return expand_increment (exp, ! ignore);
  5931.  
  5932.     case ADDR_EXPR:
  5933.       /* If nonzero, TEMP will be set to the address of something that might
  5934.      be a MEM corresponding to a stack slot. */
  5935.       temp = 0;
  5936.  
  5937.       /* Are we taking the address of a nested function?  */
  5938.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == FUNCTION_DECL
  5939.       && decl_function_context (TREE_OPERAND (exp, 0)) != 0)
  5940.     {
  5941.       op0 = trampoline_address (TREE_OPERAND (exp, 0));
  5942.       op0 = force_operand (op0, target);
  5943.     }
  5944.       /* If we are taking the address of something erroneous, just
  5945.      return a zero.  */
  5946.       else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ERROR_MARK)
  5947.     return const0_rtx;
  5948.       else
  5949.     {
  5950.       /* We make sure to pass const0_rtx down if we came in with
  5951.          ignore set, to avoid doing the cleanups twice for something.  */
  5952.       op0 = expand_expr (TREE_OPERAND (exp, 0),
  5953.                  ignore ? const0_rtx : NULL_RTX, VOIDmode,
  5954.                  (modifier == EXPAND_INITIALIZER
  5955.                   ? modifier : EXPAND_CONST_ADDRESS));
  5956.  
  5957.       /* If we are going to ignore the result, OP0 will have been set
  5958.          to const0_rtx, so just return it.  Don't get confused and
  5959.          think we are taking the address of the constant.  */
  5960.       if (ignore)
  5961.         return op0;
  5962.  
  5963.       /* We would like the object in memory.  If it is a constant,
  5964.          we can have it be statically allocated into memory.  For
  5965.          a non-constant (REG, SUBREG or CONCAT), we need to allocate some
  5966.          memory and store the value into it.  */
  5967.  
  5968.       if (CONSTANT_P (op0))
  5969.         op0 = force_const_mem (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  5970.                    op0);
  5971.       else if (GET_CODE (op0) == MEM)
  5972.         temp = XEXP (op0, 0);
  5973.  
  5974.       else if (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  5975.            || GET_CODE (op0) == CONCAT)
  5976.         {
  5977.           /* If this object is in a register, it must be not
  5978.          be BLKmode. */
  5979.           tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  5980.           enum machine_mode inner_mode = TYPE_MODE (inner_type);
  5981.           rtx memloc
  5982.         = assign_stack_temp (inner_mode,
  5983.                      int_size_in_bytes (inner_type), 1);
  5984.  
  5985.           emit_move_insn (memloc, op0);
  5986.           op0 = memloc;
  5987.         }
  5988.  
  5989.       if (GET_CODE (op0) != MEM)
  5990.         abort ();
  5991.   
  5992.       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  5993.         return XEXP (op0, 0);
  5994.  
  5995.       op0 = force_operand (XEXP (op0, 0), target);
  5996.     }
  5997.  
  5998.       if (flag_force_addr && GET_CODE (op0) != REG)
  5999.     op0 = force_reg (Pmode, op0);
  6000.  
  6001.       if (GET_CODE (op0) == REG)
  6002.     mark_reg_pointer (op0);
  6003.  
  6004.       /* If we might have had a temp slot, add an equivalent address
  6005.      for it.  */
  6006.       if (temp != 0)
  6007.     update_temp_slot_address (temp, op0);
  6008.  
  6009.       return op0;
  6010.  
  6011.     case ENTRY_VALUE_EXPR:
  6012.       abort ();
  6013.  
  6014.     /* COMPLEX type for Extended Pascal & Fortran  */
  6015.     case COMPLEX_EXPR:
  6016.       {
  6017.     enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
  6018.     rtx insns;
  6019.  
  6020.     /* Get the rtx code of the operands.  */
  6021.     op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6022.     op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  6023.  
  6024.     if (! target)
  6025.       target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  6026.  
  6027.     start_sequence ();
  6028.  
  6029.     /* Move the real (op0) and imaginary (op1) parts to their location.  */
  6030.     emit_move_insn (gen_realpart (mode, target), op0);
  6031.     emit_move_insn (gen_imagpart (mode, target), op1);
  6032.  
  6033.     insns = get_insns ();
  6034.     end_sequence ();
  6035.  
  6036.     /* Complex construction should appear as a single unit.  */
  6037.     /* If TARGET is a CONCAT, we got insns like RD = RS, ID = IS,
  6038.        each with a separate pseudo as destination.
  6039.        It's not correct for flow to treat them as a unit.  */
  6040.     if (GET_CODE (target) != CONCAT)
  6041.       emit_no_conflict_block (insns, target, op0, op1, NULL_RTX);
  6042.     else
  6043.       emit_insns (insns);
  6044.  
  6045.     return target;
  6046.       }
  6047.  
  6048.     case REALPART_EXPR:
  6049.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6050.       return gen_realpart (mode, op0);
  6051.       
  6052.     case IMAGPART_EXPR:
  6053.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6054.       return gen_imagpart (mode, op0);
  6055.  
  6056.     case CONJ_EXPR:
  6057.       {
  6058.     rtx imag_t;
  6059.     rtx insns;
  6060.     
  6061.     op0  = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6062.  
  6063.     if (! target)
  6064.       target = gen_reg_rtx (mode);
  6065.                                     
  6066.     start_sequence ();
  6067.  
  6068.     /* Store the realpart and the negated imagpart to target.  */
  6069.     emit_move_insn (gen_realpart (mode, target), gen_realpart (mode, op0));
  6070.  
  6071.     imag_t = gen_imagpart (mode, target);
  6072.     temp = expand_unop (mode, neg_optab,
  6073.                    gen_imagpart (mode, op0), imag_t, 0);
  6074.     if (temp != imag_t)
  6075.       emit_move_insn (imag_t, temp);
  6076.  
  6077.     insns = get_insns ();
  6078.     end_sequence ();
  6079.  
  6080.     /* Conjugate should appear as a single unit 
  6081.        If TARGET is a CONCAT, we got insns like RD = RS, ID = - IS,
  6082.        each with a separate pseudo as destination.
  6083.        It's not correct for flow to treat them as a unit.  */
  6084.     if (GET_CODE (target) != CONCAT)
  6085.       emit_no_conflict_block (insns, target, op0, NULL_RTX, NULL_RTX);
  6086.     else
  6087.       emit_insns (insns);
  6088.  
  6089.     return target;
  6090.       }
  6091.  
  6092.     case ERROR_MARK:
  6093.       op0 = CONST0_RTX (tmode);
  6094.       if (op0 != 0)
  6095.     return op0;
  6096.       return const0_rtx;
  6097.  
  6098.     default:
  6099.       return (*lang_expand_expr) (exp, original_target, tmode, modifier);
  6100.     }
  6101.  
  6102.   /* Here to do an ordinary binary operator, generating an instruction
  6103.      from the optab already placed in `this_optab'.  */
  6104.  binop:
  6105.   preexpand_calls (exp);
  6106.   if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  6107.     subtarget = 0;
  6108.   op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  6109.   op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  6110.  binop2:
  6111.   temp = expand_binop (mode, this_optab, op0, op1, target,
  6112.                unsignedp, OPTAB_LIB_WIDEN);
  6113.   if (temp == 0)
  6114.     abort ();
  6115.   return temp;
  6116. }
  6117.  
  6118.  
  6119. /* Emit bytecode to evaluate the given expression EXP to the stack. */
  6120. void
  6121. bc_expand_expr (exp)
  6122.     tree exp;
  6123. {
  6124.   enum tree_code code;
  6125.   tree type, arg0;
  6126.   rtx r;
  6127.   struct binary_operator *binoptab;
  6128.   struct unary_operator *unoptab;
  6129.   struct increment_operator *incroptab;
  6130.   struct bc_label *lab, *lab1;
  6131.   enum bytecode_opcode opcode;
  6132.   
  6133.   
  6134.   code = TREE_CODE (exp);
  6135.   
  6136.   switch (code)
  6137.     {
  6138.     case PARM_DECL:
  6139.       
  6140.       if (DECL_RTL (exp) == 0)
  6141.     {
  6142.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  6143.       return;
  6144.     }
  6145.       
  6146.       bc_load_parmaddr (DECL_RTL (exp));
  6147.       bc_load_memory (TREE_TYPE (exp), exp);
  6148.       
  6149.       return;
  6150.       
  6151.     case VAR_DECL:
  6152.       
  6153.       if (DECL_RTL (exp) == 0)
  6154.     abort ();
  6155.       
  6156. #if 0
  6157.       if (BYTECODE_LABEL (DECL_RTL (exp)))
  6158.     bc_load_externaddr (DECL_RTL (exp));
  6159.       else
  6160.     bc_load_localaddr (DECL_RTL (exp));
  6161. #endif
  6162.       if (TREE_PUBLIC (exp))
  6163.     bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  6164.                    BYTECODE_BC_LABEL (DECL_RTL (exp))->offset);
  6165.       else
  6166.     bc_load_localaddr (DECL_RTL (exp));
  6167.       
  6168.       bc_load_memory (TREE_TYPE (exp), exp);
  6169.       return;
  6170.       
  6171.     case INTEGER_CST:
  6172.       
  6173. #ifdef DEBUG_PRINT_CODE
  6174.       fprintf (stderr, " [%x]\n", TREE_INT_CST_LOW (exp));
  6175. #endif
  6176.       bc_emit_instruction (mode_to_const_map[(int) (DECL_BIT_FIELD (exp)
  6177.                          ? SImode
  6178.                          : TYPE_MODE (TREE_TYPE (exp)))],
  6179.                (HOST_WIDE_INT) TREE_INT_CST_LOW (exp));
  6180.       return;
  6181.       
  6182.     case REAL_CST:
  6183.       
  6184. #if 0
  6185. #ifdef DEBUG_PRINT_CODE
  6186.       fprintf (stderr, " [%g]\n", (double) TREE_INT_CST_LOW (exp));
  6187. #endif
  6188.       /* FIX THIS: find a better way to pass real_cst's. -bson */
  6189.       bc_emit_instruction (mode_to_const_map[TYPE_MODE (TREE_TYPE (exp))],
  6190.                (double) TREE_REAL_CST (exp));
  6191. #else
  6192.       abort ();
  6193. #endif
  6194.  
  6195.       return;
  6196.       
  6197.     case CALL_EXPR:
  6198.       
  6199.       /* We build a call description vector describing the type of
  6200.      the return value and of the arguments; this call vector,
  6201.      together with a pointer to a location for the return value
  6202.      and the base of the argument list, is passed to the low
  6203.      level machine dependent call subroutine, which is responsible
  6204.      for putting the arguments wherever real functions expect
  6205.      them, as well as getting the return value back.  */
  6206.       {
  6207.     tree calldesc = 0, arg;
  6208.     int nargs = 0, i;
  6209.     rtx retval;
  6210.     
  6211.     /* Push the evaluated args on the evaluation stack in reverse
  6212.        order.  Also make an entry for each arg in the calldesc
  6213.        vector while we're at it.  */
  6214.     
  6215.     TREE_OPERAND (exp, 1) = nreverse (TREE_OPERAND (exp, 1));
  6216.     
  6217.     for (arg = TREE_OPERAND (exp, 1); arg; arg = TREE_CHAIN (arg))
  6218.       {
  6219.         ++nargs;
  6220.         bc_expand_expr (TREE_VALUE (arg));
  6221.         
  6222.         calldesc = tree_cons ((tree) 0,
  6223.                   size_in_bytes (TREE_TYPE (TREE_VALUE (arg))),
  6224.                   calldesc);
  6225.         calldesc = tree_cons ((tree) 0,
  6226.                   bc_runtime_type_code (TREE_TYPE (TREE_VALUE (arg))),
  6227.                   calldesc);
  6228.       }
  6229.     
  6230.     TREE_OPERAND (exp, 1) = nreverse (TREE_OPERAND (exp, 1));
  6231.     
  6232.     /* Allocate a location for the return value and push its
  6233.        address on the evaluation stack.  Also make an entry
  6234.        at the front of the calldesc for the return value type. */
  6235.     
  6236.     type = TREE_TYPE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0))));
  6237.     retval = bc_allocate_local (int_size_in_bytes (type), TYPE_ALIGN (type));
  6238.     bc_load_localaddr (retval);
  6239.     
  6240.     calldesc = tree_cons ((tree) 0, size_in_bytes (type), calldesc);
  6241.     calldesc = tree_cons ((tree) 0, bc_runtime_type_code (type), calldesc);
  6242.     
  6243.     /* Prepend the argument count.  */
  6244.     calldesc = tree_cons ((tree) 0,
  6245.                   build_int_2 (nargs, 0),
  6246.                   calldesc);
  6247.     
  6248.     /* Push the address of the call description vector on the stack.  */
  6249.     calldesc = build_nt (CONSTRUCTOR, (tree) 0, calldesc);
  6250.     TREE_TYPE (calldesc) = build_array_type (integer_type_node,
  6251.                          build_index_type (build_int_2 (nargs * 2, 0)));
  6252.     r = output_constant_def (calldesc);
  6253.     bc_load_externaddr (r);
  6254.     
  6255.     /* Push the address of the function to be called. */
  6256.     bc_expand_expr (TREE_OPERAND (exp, 0));
  6257.     
  6258.     /* Call the function, popping its address and the calldesc vector
  6259.        address off the evaluation stack in the process.  */
  6260.     bc_emit_instruction (call);
  6261.     
  6262.     /* Pop the arguments off the stack.  */
  6263.     bc_adjust_stack (nargs);
  6264.     
  6265.     /* Load the return value onto the stack.  */
  6266.     bc_load_localaddr (retval);
  6267.     bc_load_memory (type, TREE_OPERAND (exp, 0));
  6268.       }
  6269.       return;
  6270.       
  6271.     case SAVE_EXPR:
  6272.       
  6273.       if (!SAVE_EXPR_RTL (exp))
  6274.     {
  6275.       /* First time around: copy to local variable */
  6276.       SAVE_EXPR_RTL (exp) = bc_allocate_local (int_size_in_bytes (TREE_TYPE (exp)),
  6277.                            TYPE_ALIGN (TREE_TYPE(exp)));
  6278.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6279.       bc_emit_instruction (duplicate);
  6280.       
  6281.       bc_load_localaddr (SAVE_EXPR_RTL (exp));
  6282.       bc_store_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6283.     }
  6284.       else
  6285.     {
  6286.       /* Consecutive reference: use saved copy */
  6287.       bc_load_localaddr (SAVE_EXPR_RTL (exp));
  6288.       bc_load_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6289.     }
  6290.       return;
  6291.       
  6292. #if 0
  6293.       /* FIXME: the XXXX_STMT codes have been removed in GCC2, but
  6294.      how are they handled instead? */
  6295.     case LET_STMT:
  6296.       
  6297.       TREE_USED (exp) = 1;
  6298.       bc_expand_expr (STMT_BODY (exp));
  6299.       return;
  6300. #endif
  6301.       
  6302.     case NOP_EXPR:
  6303.     case CONVERT_EXPR:
  6304.       
  6305.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6306.       bc_expand_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)), TREE_TYPE (exp));
  6307.       return;
  6308.       
  6309.     case MODIFY_EXPR:
  6310.       
  6311.       expand_assignment (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), 0, 0);
  6312.       return;
  6313.       
  6314.     case ADDR_EXPR:
  6315.       
  6316.       bc_expand_address (TREE_OPERAND (exp, 0));
  6317.       return;
  6318.       
  6319.     case INDIRECT_REF:
  6320.       
  6321.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6322.       bc_load_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6323.       return;
  6324.       
  6325.     case ARRAY_REF:
  6326.       
  6327.       bc_expand_expr (bc_canonicalize_array_ref (exp));
  6328.       return;
  6329.       
  6330.     case COMPONENT_REF:
  6331.       
  6332.       bc_expand_component_address (exp);
  6333.       
  6334.       /* If we have a bitfield, generate a proper load */
  6335.       bc_load_memory (TREE_TYPE (TREE_OPERAND (exp, 1)), TREE_OPERAND (exp, 1));
  6336.       return;
  6337.       
  6338.     case COMPOUND_EXPR:
  6339.       
  6340.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6341.       bc_emit_instruction (drop);
  6342.       bc_expand_expr (TREE_OPERAND (exp, 1));
  6343.       return;
  6344.       
  6345.     case COND_EXPR:
  6346.       
  6347.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6348.       bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)));
  6349.       lab = bc_get_bytecode_label ();
  6350.       bc_emit_bytecode (xjumpifnot);
  6351.       bc_emit_bytecode_labelref (lab);
  6352.       
  6353. #ifdef DEBUG_PRINT_CODE
  6354.       fputc ('\n', stderr);
  6355. #endif
  6356.       bc_expand_expr (TREE_OPERAND (exp, 1));
  6357.       lab1 = bc_get_bytecode_label ();
  6358.       bc_emit_bytecode (jump);
  6359.       bc_emit_bytecode_labelref (lab1);
  6360.       
  6361. #ifdef DEBUG_PRINT_CODE
  6362.       fputc ('\n', stderr);
  6363. #endif
  6364.       
  6365.       bc_emit_bytecode_labeldef (lab);
  6366.       bc_expand_expr (TREE_OPERAND (exp, 2));
  6367.       bc_emit_bytecode_labeldef (lab1);
  6368.       return;
  6369.       
  6370.     case TRUTH_ANDIF_EXPR:
  6371.       
  6372.       opcode = xjumpifnot;
  6373.       goto andorif;
  6374.       
  6375.     case TRUTH_ORIF_EXPR:
  6376.       
  6377.       opcode = xjumpif;
  6378.       goto andorif;
  6379.       
  6380.     case PLUS_EXPR:
  6381.       
  6382.       binoptab = optab_plus_expr;
  6383.       goto binop;
  6384.       
  6385.     case MINUS_EXPR:
  6386.       
  6387.       binoptab = optab_minus_expr;
  6388.       goto binop;
  6389.       
  6390.     case MULT_EXPR:
  6391.       
  6392.       binoptab = optab_mult_expr;
  6393.       goto binop;
  6394.       
  6395.     case TRUNC_DIV_EXPR:
  6396.     case FLOOR_DIV_EXPR:
  6397.     case CEIL_DIV_EXPR:
  6398.     case ROUND_DIV_EXPR:
  6399.     case EXACT_DIV_EXPR:
  6400.       
  6401.       binoptab = optab_trunc_div_expr;
  6402.       goto binop;
  6403.       
  6404.     case TRUNC_MOD_EXPR:
  6405.     case FLOOR_MOD_EXPR:
  6406.     case CEIL_MOD_EXPR:
  6407.     case ROUND_MOD_EXPR:
  6408.       
  6409.       binoptab = optab_trunc_mod_expr;
  6410.       goto binop;
  6411.       
  6412.     case FIX_ROUND_EXPR:
  6413.     case FIX_FLOOR_EXPR:
  6414.     case FIX_CEIL_EXPR:
  6415.       abort ();            /* Not used for C.  */
  6416.       
  6417.     case FIX_TRUNC_EXPR:
  6418.     case FLOAT_EXPR:
  6419.     case MAX_EXPR:
  6420.     case MIN_EXPR:
  6421.     case FFS_EXPR:
  6422.     case LROTATE_EXPR:
  6423.     case RROTATE_EXPR:
  6424.       abort ();            /* FIXME */
  6425.       
  6426.     case RDIV_EXPR:
  6427.       
  6428.       binoptab = optab_rdiv_expr;
  6429.       goto binop;
  6430.       
  6431.     case BIT_AND_EXPR:
  6432.       
  6433.       binoptab = optab_bit_and_expr;
  6434.       goto binop;
  6435.       
  6436.     case BIT_IOR_EXPR:
  6437.       
  6438.       binoptab = optab_bit_ior_expr;
  6439.       goto binop;
  6440.       
  6441.     case BIT_XOR_EXPR:
  6442.       
  6443.       binoptab = optab_bit_xor_expr;
  6444.       goto binop;
  6445.       
  6446.     case LSHIFT_EXPR:
  6447.       
  6448.       binoptab = optab_lshift_expr;
  6449.       goto binop;
  6450.       
  6451.     case RSHIFT_EXPR:
  6452.       
  6453.       binoptab = optab_rshift_expr;
  6454.       goto binop;
  6455.       
  6456.     case TRUTH_AND_EXPR:
  6457.       
  6458.       binoptab = optab_truth_and_expr;
  6459.       goto binop;
  6460.       
  6461.     case TRUTH_OR_EXPR:
  6462.       
  6463.       binoptab = optab_truth_or_expr;
  6464.       goto binop;
  6465.       
  6466.     case LT_EXPR:
  6467.       
  6468.       binoptab = optab_lt_expr;
  6469.       goto binop;
  6470.       
  6471.     case LE_EXPR:
  6472.       
  6473.       binoptab = optab_le_expr;
  6474.       goto binop;
  6475.       
  6476.     case GE_EXPR:
  6477.       
  6478.       binoptab = optab_ge_expr;
  6479.       goto binop;
  6480.       
  6481.     case GT_EXPR:
  6482.       
  6483.       binoptab = optab_gt_expr;
  6484.       goto binop;
  6485.       
  6486.     case EQ_EXPR:
  6487.       
  6488.       binoptab = optab_eq_expr;
  6489.       goto binop;
  6490.       
  6491.     case NE_EXPR:
  6492.       
  6493.       binoptab = optab_ne_expr;
  6494.       goto binop;
  6495.       
  6496.     case NEGATE_EXPR:
  6497.       
  6498.       unoptab = optab_negate_expr;
  6499.       goto unop;
  6500.       
  6501.     case BIT_NOT_EXPR:
  6502.       
  6503.       unoptab = optab_bit_not_expr;
  6504.       goto unop;
  6505.       
  6506.     case TRUTH_NOT_EXPR:
  6507.       
  6508.       unoptab = optab_truth_not_expr;
  6509.       goto unop;
  6510.       
  6511.     case PREDECREMENT_EXPR:
  6512.       
  6513.       incroptab = optab_predecrement_expr;
  6514.       goto increment;
  6515.       
  6516.     case PREINCREMENT_EXPR:
  6517.       
  6518.       incroptab = optab_preincrement_expr;
  6519.       goto increment;
  6520.       
  6521.     case POSTDECREMENT_EXPR:
  6522.       
  6523.       incroptab = optab_postdecrement_expr;
  6524.       goto increment;
  6525.       
  6526.     case POSTINCREMENT_EXPR:
  6527.       
  6528.       incroptab = optab_postincrement_expr;
  6529.       goto increment;
  6530.       
  6531.     case CONSTRUCTOR:
  6532.       
  6533.       bc_expand_constructor (exp);
  6534.       return;
  6535.       
  6536.     case ERROR_MARK:
  6537.     case RTL_EXPR:
  6538.       
  6539.       return;
  6540.       
  6541.     case BIND_EXPR:
  6542.       {
  6543.     tree vars = TREE_OPERAND (exp, 0);
  6544.     int vars_need_expansion = 0;
  6545.     
  6546.     /* Need to open a binding contour here because
  6547.        if there are any cleanups they most be contained here.  */
  6548.     expand_start_bindings (0);
  6549.     
  6550.     /* Mark the corresponding BLOCK for output.  */
  6551.     if (TREE_OPERAND (exp, 2) != 0)
  6552.       TREE_USED (TREE_OPERAND (exp, 2)) = 1;
  6553.     
  6554.     /* If VARS have not yet been expanded, expand them now.  */
  6555.     while (vars)
  6556.       {
  6557.         if (DECL_RTL (vars) == 0)
  6558.           {
  6559.         vars_need_expansion = 1;
  6560.         expand_decl (vars);
  6561.           }
  6562.         expand_decl_init (vars);
  6563.         vars = TREE_CHAIN (vars);
  6564.       }
  6565.     
  6566.     bc_expand_expr (TREE_OPERAND (exp, 1));
  6567.     
  6568.     expand_end_bindings (TREE_OPERAND (exp, 0), 0, 0);
  6569.     
  6570.     return;
  6571.       }
  6572.     }
  6573.   
  6574.   abort ();
  6575.   
  6576.  binop:
  6577.   
  6578.   bc_expand_binary_operation (binoptab, TREE_TYPE (exp),
  6579.                   TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1));
  6580.   return;
  6581.   
  6582.   
  6583.  unop:
  6584.   
  6585.   bc_expand_unary_operation (unoptab, TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6586.   return;
  6587.   
  6588.   
  6589.  andorif:
  6590.   
  6591.   bc_expand_expr (TREE_OPERAND (exp, 0));
  6592.   bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)));
  6593.   lab = bc_get_bytecode_label ();
  6594.   
  6595.   bc_emit_instruction (duplicate);
  6596.   bc_emit_bytecode (opcode);
  6597.   bc_emit_bytecode_labelref (lab);
  6598.   
  6599. #ifdef DEBUG_PRINT_CODE
  6600.   fputc ('\n', stderr);
  6601. #endif
  6602.   
  6603.   bc_emit_instruction (drop);
  6604.   
  6605.   bc_expand_expr (TREE_OPERAND (exp, 1));
  6606.   bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 1)));
  6607.   bc_emit_bytecode_labeldef (lab);
  6608.   return;
  6609.   
  6610.   
  6611.  increment:
  6612.   
  6613.   type = TREE_TYPE (TREE_OPERAND (exp, 0));
  6614.   
  6615.   /* Push the quantum.  */
  6616.   bc_expand_expr (TREE_OPERAND (exp, 1));
  6617.   
  6618.   /* Convert it to the lvalue's type.  */
  6619.   bc_expand_conversion (TREE_TYPE (TREE_OPERAND (exp, 1)), type);
  6620.   
  6621.   /* Push the address of the lvalue */
  6622.   bc_expand_expr (build1 (ADDR_EXPR, TYPE_POINTER_TO (type), TREE_OPERAND (exp, 0)));
  6623.   
  6624.   /* Perform actual increment */
  6625.   bc_expand_increment (incroptab, type);
  6626.   return;
  6627. }
  6628.  
  6629. /* Return the alignment in bits of EXP, a pointer valued expression.
  6630.    But don't return more than MAX_ALIGN no matter what.
  6631.    The alignment returned is, by default, the alignment of the thing that
  6632.    EXP points to (if it is not a POINTER_TYPE, 0 is returned).
  6633.  
  6634.    Otherwise, look at the expression to see if we can do better, i.e., if the
  6635.    expression is actually pointing at an object whose alignment is tighter.  */
  6636.  
  6637. static int
  6638. get_pointer_alignment (exp, max_align)
  6639.      tree exp;
  6640.      unsigned max_align;
  6641. {
  6642.   unsigned align, inner;
  6643.  
  6644.   if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  6645.     return 0;
  6646.  
  6647.   align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  6648.   align = MIN (align, max_align);
  6649.  
  6650.   while (1)
  6651.     {
  6652.       switch (TREE_CODE (exp))
  6653.     {
  6654.     case NOP_EXPR:
  6655.     case CONVERT_EXPR:
  6656.     case NON_LVALUE_EXPR:
  6657.       exp = TREE_OPERAND (exp, 0);
  6658.       if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  6659.         return align;
  6660.       inner = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  6661.       align = MIN (inner, max_align);
  6662.       break;
  6663.  
  6664.     case PLUS_EXPR:
  6665.       /* If sum of pointer + int, restrict our maximum alignment to that
  6666.          imposed by the integer.  If not, we can't do any better than
  6667.          ALIGN.  */
  6668.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST)
  6669.         return align;
  6670.  
  6671.       while (((TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)) * BITS_PER_UNIT)
  6672.           & (max_align - 1))
  6673.          != 0)
  6674.         max_align >>= 1;
  6675.  
  6676.       exp = TREE_OPERAND (exp, 0);
  6677.       break;
  6678.  
  6679.     case ADDR_EXPR:
  6680.       /* See what we are pointing at and look at its alignment.  */
  6681.       exp = TREE_OPERAND (exp, 0);
  6682.       if (TREE_CODE (exp) == FUNCTION_DECL)
  6683.         align = FUNCTION_BOUNDARY;
  6684.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
  6685.         align = DECL_ALIGN (exp);
  6686. #ifdef CONSTANT_ALIGNMENT
  6687.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c')
  6688.         align = CONSTANT_ALIGNMENT (exp, align);
  6689. #endif
  6690.       return MIN (align, max_align);
  6691.  
  6692.     default:
  6693.       return align;
  6694.     }
  6695.     }
  6696. }
  6697.  
  6698. /* Return the tree node and offset if a given argument corresponds to
  6699.    a string constant.  */
  6700.  
  6701. static tree
  6702. string_constant (arg, ptr_offset)
  6703.      tree arg;
  6704.      tree *ptr_offset;
  6705. {
  6706.   STRIP_NOPS (arg);
  6707.  
  6708.   if (TREE_CODE (arg) == ADDR_EXPR
  6709.       && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
  6710.     {
  6711.       *ptr_offset = integer_zero_node;
  6712.       return TREE_OPERAND (arg, 0);
  6713.     }
  6714.   else if (TREE_CODE (arg) == PLUS_EXPR)
  6715.     {
  6716.       tree arg0 = TREE_OPERAND (arg, 0);
  6717.       tree arg1 = TREE_OPERAND (arg, 1);
  6718.  
  6719.       STRIP_NOPS (arg0);
  6720.       STRIP_NOPS (arg1);
  6721.  
  6722.       if (TREE_CODE (arg0) == ADDR_EXPR
  6723.       && TREE_CODE (TREE_OPERAND (arg0, 0)) == STRING_CST)
  6724.     {
  6725.       *ptr_offset = arg1;
  6726.       return TREE_OPERAND (arg0, 0);
  6727.     }
  6728.       else if (TREE_CODE (arg1) == ADDR_EXPR
  6729.            && TREE_CODE (TREE_OPERAND (arg1, 0)) == STRING_CST)
  6730.     {
  6731.       *ptr_offset = arg0;
  6732.       return TREE_OPERAND (arg1, 0);
  6733.     }
  6734.     }
  6735.  
  6736.   return 0;
  6737. }
  6738.  
  6739. /* Compute the length of a C string.  TREE_STRING_LENGTH is not the right
  6740.    way, because it could contain a zero byte in the middle.
  6741.    TREE_STRING_LENGTH is the size of the character array, not the string.
  6742.  
  6743.    Unfortunately, string_constant can't access the values of const char
  6744.    arrays with initializers, so neither can we do so here.  */
  6745.  
  6746. static tree
  6747. c_strlen (src)
  6748.      tree src;
  6749. {
  6750.   tree offset_node;
  6751.   int offset, max;
  6752.   char *ptr;
  6753.  
  6754.   src = string_constant (src, &offset_node);
  6755.   if (src == 0)
  6756.     return 0;
  6757.   max = TREE_STRING_LENGTH (src);
  6758.   ptr = TREE_STRING_POINTER (src);
  6759.   if (offset_node && TREE_CODE (offset_node) != INTEGER_CST)
  6760.     {
  6761.       /* If the string has an internal zero byte (e.g., "foo\0bar"), we can't
  6762.      compute the offset to the following null if we don't know where to
  6763.      start searching for it.  */
  6764.       int i;
  6765.       for (i = 0; i < max; i++)
  6766.     if (ptr[i] == 0)
  6767.       return 0;
  6768.       /* We don't know the starting offset, but we do know that the string
  6769.      has no internal zero bytes.  We can assume that the offset falls
  6770.      within the bounds of the string; otherwise, the programmer deserves
  6771.      what he gets.  Subtract the offset from the length of the string,
  6772.      and return that.  */
  6773.       /* This would perhaps not be valid if we were dealing with named
  6774.          arrays in addition to literal string constants.  */
  6775.       return size_binop (MINUS_EXPR, size_int (max), offset_node);
  6776.     }
  6777.  
  6778.   /* We have a known offset into the string.  Start searching there for
  6779.      a null character.  */
  6780.   if (offset_node == 0)
  6781.     offset = 0;
  6782.   else
  6783.     {
  6784.       /* Did we get a long long offset?  If so, punt.  */
  6785.       if (TREE_INT_CST_HIGH (offset_node) != 0)
  6786.     return 0;
  6787.       offset = TREE_INT_CST_LOW (offset_node);
  6788.     }
  6789.   /* If the offset is known to be out of bounds, warn, and call strlen at
  6790.      runtime.  */
  6791.   if (offset < 0 || offset > max)
  6792.     {
  6793.       warning ("offset outside bounds of constant string");
  6794.       return 0;
  6795.     }
  6796.   /* Use strlen to search for the first zero byte.  Since any strings
  6797.      constructed with build_string will have nulls appended, we win even
  6798.      if we get handed something like (char[4])"abcd".
  6799.  
  6800.      Since OFFSET is our starting index into the string, no further
  6801.      calculation is needed.  */
  6802.   return size_int (strlen (ptr + offset));
  6803. }
  6804.  
  6805. /* Expand an expression EXP that calls a built-in function,
  6806.    with result going to TARGET if that's convenient
  6807.    (and in mode MODE if that's convenient).
  6808.    SUBTARGET may be used as the target for computing one of EXP's operands.
  6809.    IGNORE is nonzero if the value is to be ignored.  */
  6810.  
  6811. #define CALLED_AS_BUILT_IN(NODE) \
  6812.    (!strncmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__builtin_", 10))
  6813.  
  6814. static rtx
  6815. expand_builtin (exp, target, subtarget, mode, ignore)
  6816.      tree exp;
  6817.      rtx target;
  6818.      rtx subtarget;
  6819.      enum machine_mode mode;
  6820.      int ignore;
  6821. {
  6822.   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  6823.   tree arglist = TREE_OPERAND (exp, 1);
  6824.   rtx op0;
  6825.   rtx lab1, insns;
  6826.   enum machine_mode value_mode = TYPE_MODE (TREE_TYPE (exp));
  6827.   optab builtin_optab;
  6828.  
  6829.   switch (DECL_FUNCTION_CODE (fndecl))
  6830.     {
  6831.     case BUILT_IN_ABS:
  6832.     case BUILT_IN_LABS:
  6833.     case BUILT_IN_FABS:
  6834.       /* build_function_call changes these into ABS_EXPR.  */
  6835.       abort ();
  6836.  
  6837.     case BUILT_IN_SIN:
  6838.     case BUILT_IN_COS:
  6839.     case BUILT_IN_FSQRT:
  6840.       /* If not optimizing, call the library function.  */
  6841.       if (! optimize)
  6842.     break;
  6843.  
  6844.       if (arglist == 0
  6845.       /* Arg could be wrong type if user redeclared this fcn wrong.  */
  6846.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != REAL_TYPE)
  6847.     break;
  6848.  
  6849.       /* Stabilize and compute the argument.  */
  6850.       if (TREE_CODE (TREE_VALUE (arglist)) != VAR_DECL
  6851.       && TREE_CODE (TREE_VALUE (arglist)) != PARM_DECL)
  6852.     {
  6853.       exp = copy_node (exp);
  6854.       arglist = copy_node (arglist);
  6855.       TREE_OPERAND (exp, 1) = arglist;
  6856.       TREE_VALUE (arglist) = save_expr (TREE_VALUE (arglist));
  6857.     }
  6858.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  6859.  
  6860.       /* Make a suitable register to place result in.  */
  6861.       target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  6862.  
  6863.       emit_queue ();
  6864.       start_sequence ();
  6865.  
  6866.       switch (DECL_FUNCTION_CODE (fndecl))
  6867.     {
  6868.     case BUILT_IN_SIN:
  6869.       builtin_optab = sin_optab; break;
  6870.     case BUILT_IN_COS:
  6871.       builtin_optab = cos_optab; break;
  6872.     case BUILT_IN_FSQRT:
  6873.       builtin_optab = sqrt_optab; break;
  6874.     default:
  6875.       abort ();
  6876.     }
  6877.  
  6878.       /* Compute into TARGET.
  6879.      Set TARGET to wherever the result comes back.  */
  6880.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  6881.                 builtin_optab, op0, target, 0);
  6882.  
  6883.       /* If we were unable to expand via the builtin, stop the
  6884.      sequence (without outputting the insns) and break, causing
  6885.      a call the the library function.  */
  6886.       if (target == 0)
  6887.     {
  6888.       end_sequence ();
  6889.       break;
  6890.         }
  6891.  
  6892.       /* Check the results by default.  But if flag_fast_math is turned on,
  6893.      then assume sqrt will always be called with valid arguments.  */
  6894.  
  6895.       if (! flag_fast_math)
  6896.     {
  6897.       /* Don't define the builtin FP instructions
  6898.          if your machine is not IEEE.  */
  6899.       if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT)
  6900.         abort ();
  6901.  
  6902.       lab1 = gen_label_rtx ();
  6903.  
  6904.       /* Test the result; if it is NaN, set errno=EDOM because
  6905.          the argument was not in the domain.  */
  6906.       emit_cmp_insn (target, target, EQ, 0, GET_MODE (target), 0, 0);
  6907.       emit_jump_insn (gen_beq (lab1));
  6908.  
  6909. #ifdef TARGET_EDOM
  6910.       {
  6911. #ifdef GEN_ERRNO_RTX
  6912.         rtx errno_rtx = GEN_ERRNO_RTX;
  6913. #else
  6914.         rtx errno_rtx
  6915.           = gen_rtx (MEM, word_mode, gen_rtx (SYMBOL_REF, Pmode, "errno"));
  6916. #endif
  6917.  
  6918.         emit_move_insn (errno_rtx, GEN_INT (TARGET_EDOM));
  6919.       }
  6920. #else
  6921.       /* We can't set errno=EDOM directly; let the library call do it.
  6922.          Pop the arguments right away in case the call gets deleted. */
  6923.       NO_DEFER_POP;
  6924.       expand_call (exp, target, 0);
  6925.       OK_DEFER_POP;
  6926. #endif
  6927.  
  6928.       emit_label (lab1);
  6929.     }
  6930.  
  6931.       /* Output the entire sequence. */
  6932.       insns = get_insns ();
  6933.       end_sequence ();
  6934.       emit_insns (insns);
  6935.  
  6936.       return target;
  6937.  
  6938.       /* __builtin_apply_args returns block of memory allocated on
  6939.      the stack into which is stored the arg pointer, structure
  6940.      value address, static chain, and all the registers that might
  6941.      possibly be used in performing a function call.  The code is
  6942.      moved to the start of the function so the incoming values are
  6943.      saved.  */
  6944.     case BUILT_IN_APPLY_ARGS:
  6945.       /* Don't do __builtin_apply_args more than once in a function.
  6946.      Save the result of the first call and reuse it.  */
  6947.       if (apply_args_value != 0)
  6948.     return apply_args_value;
  6949.       {
  6950.     /* When this function is called, it means that registers must be
  6951.        saved on entry to this function.  So we migrate the
  6952.        call to the first insn of this function.  */
  6953.     rtx temp;
  6954.     rtx seq;
  6955.  
  6956.     start_sequence ();
  6957.     temp = expand_builtin_apply_args ();
  6958.     seq = get_insns ();
  6959.     end_sequence ();
  6960.  
  6961.     apply_args_value = temp;
  6962.  
  6963.     /* Put the sequence after the NOTE that starts the function.
  6964.        If this is inside a SEQUENCE, make the outer-level insn
  6965.        chain current, so the code is placed at the start of the
  6966.        function.  */
  6967.     push_topmost_sequence ();
  6968.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  6969.     pop_topmost_sequence ();
  6970.     return temp;
  6971.       }
  6972.  
  6973.       /* __builtin_apply (FUNCTION, ARGUMENTS, ARGSIZE) invokes
  6974.      FUNCTION with a copy of the parameters described by
  6975.      ARGUMENTS, and ARGSIZE.  It returns a block of memory
  6976.      allocated on the stack into which is stored all the registers
  6977.      that might possibly be used for returning the result of a
  6978.      function.  ARGUMENTS is the value returned by
  6979.      __builtin_apply_args.  ARGSIZE is the number of bytes of
  6980.      arguments that must be copied.  ??? How should this value be
  6981.      computed?  We'll also need a safe worst case value for varargs
  6982.      functions.  */
  6983.     case BUILT_IN_APPLY:
  6984.       if (arglist == 0
  6985.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  6986.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  6987.       || TREE_CHAIN (arglist) == 0
  6988.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  6989.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  6990.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  6991.     return const0_rtx;
  6992.       else
  6993.     {
  6994.       int i;
  6995.       tree t;
  6996.       rtx ops[3];
  6997.  
  6998.       for (t = arglist, i = 0; t; t = TREE_CHAIN (t), i++)
  6999.         ops[i] = expand_expr (TREE_VALUE (t), NULL_RTX, VOIDmode, 0);
  7000.  
  7001.       return expand_builtin_apply (ops[0], ops[1], ops[2]);
  7002.     }
  7003.  
  7004.       /* __builtin_return (RESULT) causes the function to return the
  7005.      value described by RESULT.  RESULT is address of the block of
  7006.      memory returned by __builtin_apply.  */
  7007.     case BUILT_IN_RETURN:
  7008.       if (arglist
  7009.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7010.       && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE)
  7011.     expand_builtin_return (expand_expr (TREE_VALUE (arglist),
  7012.                         NULL_RTX, VOIDmode, 0));
  7013.       return const0_rtx;
  7014.  
  7015.     case BUILT_IN_SAVEREGS:
  7016.       /* Don't do __builtin_saveregs more than once in a function.
  7017.      Save the result of the first call and reuse it.  */
  7018.       if (saveregs_value != 0)
  7019.     return saveregs_value;
  7020.       {
  7021.     /* When this function is called, it means that registers must be
  7022.        saved on entry to this function.  So we migrate the
  7023.        call to the first insn of this function.  */
  7024.     rtx temp;
  7025.     rtx seq;
  7026.  
  7027.     /* Now really call the function.  `expand_call' does not call
  7028.        expand_builtin, so there is no danger of infinite recursion here.  */
  7029.     start_sequence ();
  7030.  
  7031. #ifdef EXPAND_BUILTIN_SAVEREGS
  7032.     /* Do whatever the machine needs done in this case.  */
  7033.     temp = EXPAND_BUILTIN_SAVEREGS (arglist);
  7034. #else
  7035.     /* The register where the function returns its value
  7036.        is likely to have something else in it, such as an argument.
  7037.        So preserve that register around the call.  */
  7038.  
  7039.     if (value_mode != VOIDmode)
  7040.       {
  7041.         rtx valreg = hard_libcall_value (value_mode);
  7042.         rtx saved_valreg = gen_reg_rtx (value_mode);
  7043.  
  7044.         emit_move_insn (saved_valreg, valreg);
  7045.         temp = expand_call (exp, target, ignore);
  7046.         emit_move_insn (valreg, saved_valreg);
  7047.       }
  7048.     else
  7049.       /* Generate the call, putting the value in a pseudo.  */
  7050.       temp = expand_call (exp, target, ignore);
  7051. #endif
  7052.  
  7053.     seq = get_insns ();
  7054.     end_sequence ();
  7055.  
  7056.     saveregs_value = temp;
  7057.  
  7058.     /* Put the sequence after the NOTE that starts the function.
  7059.        If this is inside a SEQUENCE, make the outer-level insn
  7060.        chain current, so the code is placed at the start of the
  7061.        function.  */
  7062.     push_topmost_sequence ();
  7063.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  7064.     pop_topmost_sequence ();
  7065.     return temp;
  7066.       }
  7067.  
  7068.       /* __builtin_args_info (N) returns word N of the arg space info
  7069.      for the current function.  The number and meanings of words
  7070.      is controlled by the definition of CUMULATIVE_ARGS.  */
  7071.     case BUILT_IN_ARGS_INFO:
  7072.       {
  7073.     int nwords = sizeof (CUMULATIVE_ARGS) / sizeof (int);
  7074.     int i;
  7075.     int *word_ptr = (int *) ¤t_function_args_info;
  7076.     tree type, elts, result;
  7077.  
  7078.     if (sizeof (CUMULATIVE_ARGS) % sizeof (int) != 0)
  7079.       fatal ("CUMULATIVE_ARGS type defined badly; see %s, line %d",
  7080.          __FILE__, __LINE__);
  7081.  
  7082.     if (arglist != 0)
  7083.       {
  7084.         tree arg = TREE_VALUE (arglist);
  7085.         if (TREE_CODE (arg) != INTEGER_CST)
  7086.           error ("argument of `__builtin_args_info' must be constant");
  7087.         else
  7088.           {
  7089.         int wordnum = TREE_INT_CST_LOW (arg);
  7090.  
  7091.         if (wordnum < 0 || wordnum >= nwords || TREE_INT_CST_HIGH (arg))
  7092.           error ("argument of `__builtin_args_info' out of range");
  7093.         else
  7094.           return GEN_INT (word_ptr[wordnum]);
  7095.           }
  7096.       }
  7097.     else
  7098.       error ("missing argument in `__builtin_args_info'");
  7099.  
  7100.     return const0_rtx;
  7101.  
  7102. #if 0
  7103.     for (i = 0; i < nwords; i++)
  7104.       elts = tree_cons (NULL_TREE, build_int_2 (word_ptr[i], 0));
  7105.  
  7106.     type = build_array_type (integer_type_node,
  7107.                  build_index_type (build_int_2 (nwords, 0)));
  7108.     result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (elts));
  7109.     TREE_CONSTANT (result) = 1;
  7110.     TREE_STATIC (result) = 1;
  7111.     result = build (INDIRECT_REF, build_pointer_type (type), result);
  7112.     TREE_CONSTANT (result) = 1;
  7113.     return expand_expr (result, NULL_RTX, VOIDmode, 0);
  7114. #endif
  7115.       }
  7116.  
  7117.       /* Return the address of the first anonymous stack arg.  */
  7118.     case BUILT_IN_NEXT_ARG:
  7119.       {
  7120.     tree fntype = TREE_TYPE (current_function_decl);
  7121.  
  7122.     if ((TYPE_ARG_TYPES (fntype) == 0
  7123.          || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  7124.          == void_type_node))
  7125.         && ! current_function_varargs)
  7126.       {
  7127.         error ("`va_start' used in function with fixed args");
  7128.         return const0_rtx;
  7129.       }
  7130.  
  7131.     if (arglist)
  7132.       {
  7133.         tree last_parm = tree_last (DECL_ARGUMENTS (current_function_decl));
  7134.         tree arg = TREE_VALUE (arglist);
  7135.  
  7136.         /* Strip off all nops for the sake of the comparison.  This
  7137.            is not quite the same as STRIP_NOPS.  It does more.  */
  7138.         while (TREE_CODE (arg) == NOP_EXPR
  7139.            || TREE_CODE (arg) == CONVERT_EXPR
  7140.            || TREE_CODE (arg) == NON_LVALUE_EXPR)
  7141.           arg = TREE_OPERAND (arg, 0);
  7142.         if (arg != last_parm)
  7143.           warning ("second parameter of `va_start' not last named argument");
  7144.       }
  7145.     else
  7146.       /* Evidently an out of date version of <stdarg.h>; can't validate
  7147.          va_start's second argument, but can still work as intended.  */
  7148.       warning ("`__builtin_next_arg' called without an argument");
  7149.       }
  7150.  
  7151.       return expand_binop (Pmode, add_optab,
  7152.                current_function_internal_arg_pointer,
  7153.                current_function_arg_offset_rtx,
  7154.                NULL_RTX, 0, OPTAB_LIB_WIDEN);
  7155.  
  7156.     case BUILT_IN_CLASSIFY_TYPE:
  7157.       if (arglist != 0)
  7158.     {
  7159.       tree type = TREE_TYPE (TREE_VALUE (arglist));
  7160.       enum tree_code code = TREE_CODE (type);
  7161.       if (code == VOID_TYPE)
  7162.         return GEN_INT (void_type_class);
  7163.       if (code == INTEGER_TYPE)
  7164.         return GEN_INT (integer_type_class);
  7165.       if (code == CHAR_TYPE)
  7166.         return GEN_INT (char_type_class);
  7167.       if (code == ENUMERAL_TYPE)
  7168.         return GEN_INT (enumeral_type_class);
  7169.       if (code == BOOLEAN_TYPE)
  7170.         return GEN_INT (boolean_type_class);
  7171.       if (code == POINTER_TYPE)
  7172.         return GEN_INT (pointer_type_class);
  7173.       if (code == REFERENCE_TYPE)
  7174.         return GEN_INT (reference_type_class);
  7175.       if (code == OFFSET_TYPE)
  7176.         return GEN_INT (offset_type_class);
  7177.       if (code == REAL_TYPE)
  7178.         return GEN_INT (real_type_class);
  7179.       if (code == COMPLEX_TYPE)
  7180.         return GEN_INT (complex_type_class);
  7181.       if (code == FUNCTION_TYPE)
  7182.         return GEN_INT (function_type_class);
  7183.       if (code == METHOD_TYPE)
  7184.         return GEN_INT (method_type_class);
  7185.       if (code == RECORD_TYPE)
  7186.         return GEN_INT (record_type_class);
  7187.       if (code == UNION_TYPE || code == QUAL_UNION_TYPE)
  7188.         return GEN_INT (union_type_class);
  7189.       if (code == ARRAY_TYPE)
  7190.         {
  7191.           if (TYPE_STRING_FLAG (type))
  7192.         return GEN_INT (string_type_class);
  7193.           else
  7194.         return GEN_INT (array_type_class);
  7195.         }
  7196.       if (code == SET_TYPE)
  7197.         return GEN_INT (set_type_class);
  7198.       if (code == FILE_TYPE)
  7199.         return GEN_INT (file_type_class);
  7200.       if (code == LANG_TYPE)
  7201.         return GEN_INT (lang_type_class);
  7202.     }
  7203.       return GEN_INT (no_type_class);
  7204.  
  7205.     case BUILT_IN_CONSTANT_P:
  7206.       if (arglist == 0)
  7207.     return const0_rtx;
  7208.       else
  7209.     return (TREE_CODE_CLASS (TREE_CODE (TREE_VALUE (arglist))) == 'c'
  7210.         ? const1_rtx : const0_rtx);
  7211.  
  7212.     case BUILT_IN_FRAME_ADDRESS:
  7213.       /* The argument must be a nonnegative integer constant.
  7214.      It counts the number of frames to scan up the stack.
  7215.      The value is the address of that frame.  */
  7216.     case BUILT_IN_RETURN_ADDRESS:
  7217.       /* The argument must be a nonnegative integer constant.
  7218.      It counts the number of frames to scan up the stack.
  7219.      The value is the return address saved in that frame.  */
  7220.       if (arglist == 0)
  7221.     /* Warning about missing arg was already issued.  */
  7222.     return const0_rtx;
  7223.       else if (TREE_CODE (TREE_VALUE (arglist)) != INTEGER_CST)
  7224.     {
  7225.       error ("invalid arg to `__builtin_return_address'");
  7226.       return const0_rtx;
  7227.     }
  7228.       else if (tree_int_cst_sgn (TREE_VALUE (arglist)) < 0)
  7229.     {
  7230.       error ("invalid arg to `__builtin_return_address'");
  7231.       return const0_rtx;
  7232.     }
  7233.       else
  7234.     {
  7235.       int count = TREE_INT_CST_LOW (TREE_VALUE (arglist)); 
  7236.       rtx tem = frame_pointer_rtx;
  7237.       int i;
  7238.  
  7239.       /* Some machines need special handling before we can access arbitrary
  7240.          frames.  For example, on the sparc, we must first flush all
  7241.          register windows to the stack.  */
  7242. #ifdef SETUP_FRAME_ADDRESSES
  7243.       SETUP_FRAME_ADDRESSES ();
  7244. #endif
  7245.  
  7246.       /* On the sparc, the return address is not in the frame, it is
  7247.          in a register.  There is no way to access it off of the current
  7248.          frame pointer, but it can be accessed off the previous frame
  7249.          pointer by reading the value from the register window save
  7250.          area.  */
  7251. #ifdef RETURN_ADDR_IN_PREVIOUS_FRAME
  7252.       if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_RETURN_ADDRESS)
  7253.         count--;
  7254. #endif
  7255.  
  7256.       /* Scan back COUNT frames to the specified frame.  */
  7257.       for (i = 0; i < count; i++)
  7258.         {
  7259.           /* Assume the dynamic chain pointer is in the word that
  7260.          the frame address points to, unless otherwise specified.  */
  7261. #ifdef DYNAMIC_CHAIN_ADDRESS
  7262.           tem = DYNAMIC_CHAIN_ADDRESS (tem);
  7263. #endif
  7264.           tem = memory_address (Pmode, tem);
  7265.           tem = copy_to_reg (gen_rtx (MEM, Pmode, tem));
  7266.         }
  7267.  
  7268.       /* For __builtin_frame_address, return what we've got.  */
  7269.       if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FRAME_ADDRESS)
  7270.         return tem;
  7271.  
  7272.       /* For __builtin_return_address,
  7273.          Get the return address from that frame.  */
  7274. #ifdef RETURN_ADDR_RTX
  7275.       return RETURN_ADDR_RTX (count, tem);
  7276. #else
  7277.       tem = memory_address (Pmode,
  7278.                 plus_constant (tem, GET_MODE_SIZE (Pmode)));
  7279.       return copy_to_reg (gen_rtx (MEM, Pmode, tem));
  7280. #endif
  7281.     }
  7282.  
  7283.     case BUILT_IN_ALLOCA:
  7284.       if (arglist == 0
  7285.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  7286.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  7287.     break;
  7288.  
  7289.       /* Compute the argument.  */
  7290.       op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
  7291.  
  7292.       /* Allocate the desired space.  */
  7293.       return allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
  7294.  
  7295.     case BUILT_IN_FFS:
  7296.       /* If not optimizing, call the library function.  */
  7297.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7298.     break;
  7299.  
  7300.       if (arglist == 0
  7301.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  7302.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  7303.     break;
  7304.  
  7305.       /* Compute the argument.  */
  7306.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  7307.       /* Compute ffs, into TARGET if possible.
  7308.      Set TARGET to wherever the result comes back.  */
  7309.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  7310.                 ffs_optab, op0, target, 1);
  7311.       if (target == 0)
  7312.     abort ();
  7313.       return target;
  7314.  
  7315.     case BUILT_IN_STRLEN:
  7316.       /* If not optimizing, call the library function.  */
  7317.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7318.     break;
  7319.  
  7320.       if (arglist == 0
  7321.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7322.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE)
  7323.     break;
  7324.       else
  7325.     {
  7326.       tree src = TREE_VALUE (arglist);
  7327.       tree len = c_strlen (src);
  7328.  
  7329.       int align
  7330.         = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7331.  
  7332.       rtx result, src_rtx, char_rtx;
  7333.       enum machine_mode insn_mode = value_mode, char_mode;
  7334.       enum insn_code icode;
  7335.  
  7336.       /* If the length is known, just return it. */
  7337.       if (len != 0)
  7338.         return expand_expr (len, target, mode, 0);
  7339.  
  7340.       /* If SRC is not a pointer type, don't do this operation inline. */
  7341.       if (align == 0)
  7342.         break;
  7343.  
  7344.       /* Call a function if we can't compute strlen in the right mode. */
  7345.  
  7346.       while (insn_mode != VOIDmode)
  7347.         {
  7348.           icode = strlen_optab->handlers[(int) insn_mode].insn_code;
  7349.           if (icode != CODE_FOR_nothing)
  7350.         break;
  7351.  
  7352.           insn_mode = GET_MODE_WIDER_MODE (insn_mode);
  7353.         }
  7354.       if (insn_mode == VOIDmode)
  7355.         break;
  7356.  
  7357.       /* Make a place to write the result of the instruction.  */
  7358.       result = target;
  7359.       if (! (result != 0
  7360.          && GET_CODE (result) == REG
  7361.          && GET_MODE (result) == insn_mode
  7362.          && REGNO (result) >= FIRST_PSEUDO_REGISTER))
  7363.         result = gen_reg_rtx (insn_mode);
  7364.  
  7365.       /* Make sure the operands are acceptable to the predicates.  */
  7366.  
  7367.       if (! (*insn_operand_predicate[(int)icode][0]) (result, insn_mode))
  7368.         result = gen_reg_rtx (insn_mode);
  7369.  
  7370.       src_rtx = memory_address (BLKmode,
  7371.                     expand_expr (src, NULL_RTX, Pmode,
  7372.                          EXPAND_NORMAL));
  7373.       if (! (*insn_operand_predicate[(int)icode][1]) (src_rtx, Pmode))
  7374.         src_rtx = copy_to_mode_reg (Pmode, src_rtx);
  7375.  
  7376.       char_rtx = const0_rtx;
  7377.       char_mode = insn_operand_mode[(int)icode][2];
  7378.       if (! (*insn_operand_predicate[(int)icode][2]) (char_rtx, char_mode))
  7379.         char_rtx = copy_to_mode_reg (char_mode, char_rtx);
  7380.  
  7381.       emit_insn (GEN_FCN (icode) (result,
  7382.                       gen_rtx (MEM, BLKmode, src_rtx),
  7383.                       char_rtx, GEN_INT (align)));
  7384.  
  7385.       /* Return the value in the proper mode for this function.  */
  7386.       if (GET_MODE (result) == value_mode)
  7387.         return result;
  7388.       else if (target != 0)
  7389.         {
  7390.           convert_move (target, result, 0);
  7391.           return target;
  7392.         }
  7393.       else
  7394.         return convert_to_mode (value_mode, result, 0);
  7395.     }
  7396.  
  7397.     case BUILT_IN_STRCPY:
  7398.       /* If not optimizing, call the library function.  */
  7399.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7400.     break;
  7401.  
  7402.       if (arglist == 0
  7403.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7404.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7405.       || TREE_CHAIN (arglist) == 0
  7406.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE)
  7407.     break;
  7408.       else
  7409.     {
  7410.       tree len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)));
  7411.  
  7412.       if (len == 0)
  7413.         break;
  7414.  
  7415.       len = size_binop (PLUS_EXPR, len, integer_one_node);
  7416.  
  7417.       chainon (arglist, build_tree_list (NULL_TREE, len));
  7418.     }
  7419.  
  7420.       /* Drops in.  */
  7421.     case BUILT_IN_MEMCPY:
  7422.       /* If not optimizing, call the library function.  */
  7423.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7424.     break;
  7425.  
  7426.       if (arglist == 0
  7427.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7428.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7429.       || TREE_CHAIN (arglist) == 0
  7430.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7431.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7432.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7433.     break;
  7434.       else
  7435.     {
  7436.       tree dest = TREE_VALUE (arglist);
  7437.       tree src = TREE_VALUE (TREE_CHAIN (arglist));
  7438.       tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  7439.  
  7440.       int src_align
  7441.         = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7442.       int dest_align
  7443.         = get_pointer_alignment (dest, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7444.       rtx dest_rtx, dest_mem, src_mem;
  7445.  
  7446.       /* If either SRC or DEST is not a pointer type, don't do
  7447.          this operation in-line.  */
  7448.       if (src_align == 0 || dest_align == 0)
  7449.         {
  7450.           if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRCPY)
  7451.         TREE_CHAIN (TREE_CHAIN (arglist)) = 0;
  7452.           break;
  7453.         }
  7454.  
  7455.       dest_rtx = expand_expr (dest, NULL_RTX, Pmode, EXPAND_NORMAL);
  7456.       dest_mem = gen_rtx (MEM, BLKmode,
  7457.                   memory_address (BLKmode, dest_rtx));
  7458.       src_mem = gen_rtx (MEM, BLKmode,
  7459.                  memory_address (BLKmode,
  7460.                          expand_expr (src, NULL_RTX,
  7461.                               Pmode,
  7462.                               EXPAND_NORMAL)));
  7463.  
  7464.       /* Copy word part most expediently.  */
  7465.       emit_block_move (dest_mem, src_mem,
  7466.                expand_expr (len, NULL_RTX, VOIDmode, 0),
  7467.                MIN (src_align, dest_align));
  7468.       return dest_rtx;
  7469.     }
  7470.  
  7471. /* These comparison functions need an instruction that returns an actual
  7472.    index.  An ordinary compare that just sets the condition codes
  7473.    is not enough.  */
  7474. #ifdef HAVE_cmpstrsi
  7475.     case BUILT_IN_STRCMP:
  7476.       /* If not optimizing, call the library function.  */
  7477.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7478.     break;
  7479.  
  7480.       if (arglist == 0
  7481.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7482.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7483.       || TREE_CHAIN (arglist) == 0
  7484.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE)
  7485.     break;
  7486.       else if (!HAVE_cmpstrsi)
  7487.     break;
  7488.       {
  7489.     tree arg1 = TREE_VALUE (arglist);
  7490.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  7491.     tree offset;
  7492.     tree len, len2;
  7493.  
  7494.     len = c_strlen (arg1);
  7495.     if (len)
  7496.       len = size_binop (PLUS_EXPR, integer_one_node, len);
  7497.     len2 = c_strlen (arg2);
  7498.     if (len2)
  7499.       len2 = size_binop (PLUS_EXPR, integer_one_node, len2);
  7500.  
  7501.     /* If we don't have a constant length for the first, use the length
  7502.        of the second, if we know it.  We don't require a constant for
  7503.        this case; some cost analysis could be done if both are available
  7504.        but neither is constant.  For now, assume they're equally cheap.
  7505.  
  7506.        If both strings have constant lengths, use the smaller.  This
  7507.        could arise if optimization results in strcpy being called with
  7508.        two fixed strings, or if the code was machine-generated.  We should
  7509.        add some code to the `memcmp' handler below to deal with such
  7510.        situations, someday.  */
  7511.     if (!len || TREE_CODE (len) != INTEGER_CST)
  7512.       {
  7513.         if (len2)
  7514.           len = len2;
  7515.         else if (len == 0)
  7516.           break;
  7517.       }
  7518.     else if (len2 && TREE_CODE (len2) == INTEGER_CST)
  7519.       {
  7520.         if (tree_int_cst_lt (len2, len))
  7521.           len = len2;
  7522.       }
  7523.  
  7524.     chainon (arglist, build_tree_list (NULL_TREE, len));
  7525.       }
  7526.  
  7527.       /* Drops in.  */
  7528.     case BUILT_IN_MEMCMP:
  7529.       /* If not optimizing, call the library function.  */
  7530.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7531.     break;
  7532.  
  7533.       if (arglist == 0
  7534.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7535.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7536.       || TREE_CHAIN (arglist) == 0
  7537.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7538.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7539.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7540.     break;
  7541.       else if (!HAVE_cmpstrsi)
  7542.     break;
  7543.       {
  7544.     tree arg1 = TREE_VALUE (arglist);
  7545.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  7546.     tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  7547.     rtx result;
  7548.  
  7549.     int arg1_align
  7550.       = get_pointer_alignment (arg1, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7551.     int arg2_align
  7552.       = get_pointer_alignment (arg2, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7553.     enum machine_mode insn_mode
  7554.       = insn_operand_mode[(int) CODE_FOR_cmpstrsi][0];
  7555.  
  7556.     /* If we don't have POINTER_TYPE, call the function.  */
  7557.     if (arg1_align == 0 || arg2_align == 0)
  7558.       {
  7559.         if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRCMP)
  7560.           TREE_CHAIN (TREE_CHAIN (arglist)) = 0;
  7561.         break;
  7562.       }
  7563.  
  7564.     /* Make a place to write the result of the instruction.  */
  7565.     result = target;
  7566.     if (! (result != 0
  7567.            && GET_CODE (result) == REG && GET_MODE (result) == insn_mode
  7568.            && REGNO (result) >= FIRST_PSEUDO_REGISTER))
  7569.       result = gen_reg_rtx (insn_mode);
  7570.  
  7571.     emit_insn (gen_cmpstrsi (result,
  7572.                  gen_rtx (MEM, BLKmode,
  7573.                       expand_expr (arg1, NULL_RTX, Pmode,
  7574.                                EXPAND_NORMAL)),
  7575.                  gen_rtx (MEM, BLKmode,
  7576.                       expand_expr (arg2, NULL_RTX, Pmode,
  7577.                                EXPAND_NORMAL)),
  7578.                  expand_expr (len, NULL_RTX, VOIDmode, 0),
  7579.                  GEN_INT (MIN (arg1_align, arg2_align))));
  7580.  
  7581.     /* Return the value in the proper mode for this function.  */
  7582.     mode = TYPE_MODE (TREE_TYPE (exp));
  7583.     if (GET_MODE (result) == mode)
  7584.       return result;
  7585.     else if (target != 0)
  7586.       {
  7587.         convert_move (target, result, 0);
  7588.         return target;
  7589.       }
  7590.     else
  7591.       return convert_to_mode (mode, result, 0);
  7592.       }    
  7593. #else
  7594.     case BUILT_IN_STRCMP:
  7595.     case BUILT_IN_MEMCMP:
  7596.       break;
  7597. #endif
  7598.  
  7599.     default:            /* just do library call, if unknown builtin */
  7600.       error ("built-in function `%s' not currently supported",
  7601.          IDENTIFIER_POINTER (DECL_NAME (fndecl)));
  7602.     }
  7603.  
  7604.   /* The switch statement above can drop through to cause the function
  7605.      to be called normally.  */
  7606.  
  7607.   return expand_call (exp, target, ignore);
  7608. }
  7609.  
  7610. /* Built-in functions to perform an untyped call and return.  */
  7611.  
  7612. /* For each register that may be used for calling a function, this
  7613.    gives a mode used to copy the register's value.  VOIDmode indicates
  7614.    the register is not used for calling a function.  If the machine
  7615.    has register windows, this gives only the outbound registers.
  7616.    INCOMING_REGNO gives the corresponding inbound register.  */
  7617. static enum machine_mode apply_args_mode[FIRST_PSEUDO_REGISTER];
  7618.  
  7619. /* For each register that may be used for returning values, this gives
  7620.    a mode used to copy the register's value.  VOIDmode indicates the
  7621.    register is not used for returning values.  If the machine has
  7622.    register windows, this gives only the outbound registers.
  7623.    INCOMING_REGNO gives the corresponding inbound register.  */
  7624. static enum machine_mode apply_result_mode[FIRST_PSEUDO_REGISTER];
  7625.  
  7626. /* For each register that may be used for calling a function, this
  7627.    gives the offset of that register into the block returned by
  7628.    __bultin_apply_args.  0 indicates that the register is not
  7629.    used for calling a function. */
  7630. static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER];
  7631.  
  7632. /* Return the offset of register REGNO into the block returned by 
  7633.    __builtin_apply_args.  This is not declared static, since it is
  7634.    needed in objc-act.c. */
  7635.  
  7636. int 
  7637. apply_args_register_offset (regno)
  7638.      int regno;
  7639. {
  7640.   apply_args_size ();
  7641.  
  7642.   /* Arguments are always put in outgoing registers (in the argument
  7643.      block) if such make sense. */
  7644. #ifdef OUTGOING_REGNO
  7645.   regno = OUTGOING_REGNO(regno);
  7646. #endif
  7647.   return apply_args_reg_offset[regno];
  7648. }
  7649.  
  7650. /* Return the size required for the block returned by __builtin_apply_args,
  7651.    and initialize apply_args_mode.  */
  7652.  
  7653. static int
  7654. apply_args_size ()
  7655. {
  7656.   static int size = -1;
  7657.   int align, regno;
  7658.   enum machine_mode mode;
  7659.  
  7660.   /* The values computed by this function never change.  */
  7661.   if (size < 0)
  7662.     {
  7663.       /* The first value is the incoming arg-pointer.  */
  7664.       size = GET_MODE_SIZE (Pmode);
  7665.  
  7666.       /* The second value is the structure value address unless this is
  7667.      passed as an "invisible" first argument.  */
  7668.       if (struct_value_rtx)
  7669.     size += GET_MODE_SIZE (Pmode);
  7670.  
  7671.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  7672.     if (FUNCTION_ARG_REGNO_P (regno))
  7673.       {
  7674.         /* Search for the proper mode for copying this register's
  7675.            value.  I'm not sure this is right, but it works so far.  */
  7676.         enum machine_mode best_mode = VOIDmode;
  7677.  
  7678.         for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  7679.          mode != VOIDmode;
  7680.          mode = GET_MODE_WIDER_MODE (mode))
  7681.           if (HARD_REGNO_MODE_OK (regno, mode)
  7682.           && HARD_REGNO_NREGS (regno, mode) == 1)
  7683.         best_mode = mode;
  7684.  
  7685.         if (best_mode == VOIDmode)
  7686.           for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
  7687.            mode != VOIDmode;
  7688.            mode = GET_MODE_WIDER_MODE (mode))
  7689.         if (HARD_REGNO_MODE_OK (regno, mode)
  7690.             && (mov_optab->handlers[(int) mode].insn_code
  7691.             != CODE_FOR_nothing))
  7692.           best_mode = mode;
  7693.  
  7694.         mode = best_mode;
  7695.         if (mode == VOIDmode)
  7696.           abort ();
  7697.  
  7698.         align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  7699.         if (size % align != 0)
  7700.           size = CEIL (size, align) * align;
  7701.         apply_args_reg_offset[regno] = size;
  7702.         size += GET_MODE_SIZE (mode);
  7703.         apply_args_mode[regno] = mode;
  7704.       }
  7705.     else
  7706.       {
  7707.         apply_args_mode[regno] = VOIDmode;
  7708.         apply_args_reg_offset[regno] = 0;
  7709.       }
  7710.     }
  7711.   return size;
  7712. }
  7713.  
  7714. /* Return the size required for the block returned by __builtin_apply,
  7715.    and initialize apply_result_mode.  */
  7716.  
  7717. static int
  7718. apply_result_size ()
  7719. {
  7720.   static int size = -1;
  7721.   int align, regno;
  7722.   enum machine_mode mode;
  7723.  
  7724.   /* The values computed by this function never change.  */
  7725.   if (size < 0)
  7726.     {
  7727.       size = 0;
  7728.  
  7729.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  7730.     if (FUNCTION_VALUE_REGNO_P (regno))
  7731.       {
  7732.         /* Search for the proper mode for copying this register's
  7733.            value.  I'm not sure this is right, but it works so far.  */
  7734.         enum machine_mode best_mode = VOIDmode;
  7735.  
  7736.         for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  7737.          mode != TImode;
  7738.          mode = GET_MODE_WIDER_MODE (mode))
  7739.           if (HARD_REGNO_MODE_OK (regno, mode))
  7740.         best_mode = mode;
  7741.  
  7742.         if (best_mode == VOIDmode)
  7743.           for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
  7744.            mode != VOIDmode;
  7745.            mode = GET_MODE_WIDER_MODE (mode))
  7746.         if (HARD_REGNO_MODE_OK (regno, mode)
  7747.             && (mov_optab->handlers[(int) mode].insn_code
  7748.             != CODE_FOR_nothing))
  7749.           best_mode = mode;
  7750.  
  7751.         mode = best_mode;
  7752.         if (mode == VOIDmode)
  7753.           abort ();
  7754.  
  7755.         align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  7756.         if (size % align != 0)
  7757.           size = CEIL (size, align) * align;
  7758.         size += GET_MODE_SIZE (mode);
  7759.         apply_result_mode[regno] = mode;
  7760.       }
  7761.     else
  7762.       apply_result_mode[regno] = VOIDmode;
  7763.  
  7764.       /* Allow targets that use untyped_call and untyped_return to override
  7765.      the size so that machine-specific information can be stored here.  */
  7766. #ifdef APPLY_RESULT_SIZE
  7767.       size = APPLY_RESULT_SIZE;
  7768. #endif
  7769.     }
  7770.   return size;
  7771. }
  7772.  
  7773. #if defined (HAVE_untyped_call) || defined (HAVE_untyped_return)
  7774. /* Create a vector describing the result block RESULT.  If SAVEP is true,
  7775.    the result block is used to save the values; otherwise it is used to
  7776.    restore the values.  */
  7777.  
  7778. static rtx
  7779. result_vector (savep, result)
  7780.      int savep;
  7781.      rtx result;
  7782. {
  7783.   int regno, size, align, nelts;
  7784.   enum machine_mode mode;
  7785.   rtx reg, mem;
  7786.   rtx *savevec = (rtx *) alloca (FIRST_PSEUDO_REGISTER * sizeof (rtx));
  7787.   
  7788.   size = nelts = 0;
  7789.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  7790.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  7791.       {
  7792.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  7793.     if (size % align != 0)
  7794.       size = CEIL (size, align) * align;
  7795.     reg = gen_rtx (REG, mode, savep ? INCOMING_REGNO (regno) : regno);
  7796.     mem = change_address (result, mode,
  7797.                   plus_constant (XEXP (result, 0), size));
  7798.     savevec[nelts++] = (savep
  7799.                 ? gen_rtx (SET, VOIDmode, mem, reg)
  7800.                 : gen_rtx (SET, VOIDmode, reg, mem));
  7801.     size += GET_MODE_SIZE (mode);
  7802.       }
  7803.   return gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (nelts, savevec));
  7804. }
  7805. #endif /* HAVE_untyped_call or HAVE_untyped_return */
  7806.  
  7807. /* Save the state required to perform an untyped call with the same
  7808.    arguments as were passed to the current function.  */
  7809.  
  7810. static rtx
  7811. expand_builtin_apply_args ()
  7812. {
  7813.   rtx registers;
  7814.   int size, align, regno;
  7815.   enum machine_mode mode;
  7816.  
  7817.   /* Create a block where the arg-pointer, structure value address,
  7818.      and argument registers can be saved.  */
  7819.   registers = assign_stack_local (BLKmode, apply_args_size (), -1);
  7820.  
  7821.   /* Walk past the arg-pointer and structure value address.  */
  7822.   size = GET_MODE_SIZE (Pmode);
  7823.   if (struct_value_rtx)
  7824.     size += GET_MODE_SIZE (Pmode);
  7825.  
  7826.   /* Save each register used in calling a function to the block.  */
  7827.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  7828.     if ((mode = apply_args_mode[regno]) != VOIDmode)
  7829.       {
  7830.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  7831.     if (size % align != 0)
  7832.       size = CEIL (size, align) * align;
  7833.     emit_move_insn (change_address (registers, mode,
  7834.                     plus_constant (XEXP (registers, 0),
  7835.                                size)),
  7836.             gen_rtx (REG, mode, INCOMING_REGNO (regno)));
  7837.     size += GET_MODE_SIZE (mode);
  7838.       }
  7839.  
  7840.   /* Save the arg pointer to the block.  */
  7841.   emit_move_insn (change_address (registers, Pmode, XEXP (registers, 0)),
  7842.           copy_to_reg (virtual_incoming_args_rtx));
  7843.   size = GET_MODE_SIZE (Pmode);
  7844.  
  7845.   /* Save the structure value address unless this is passed as an
  7846.      "invisible" first argument.  */
  7847.   if (struct_value_incoming_rtx)
  7848.     {
  7849.       emit_move_insn (change_address (registers, Pmode,
  7850.                       plus_constant (XEXP (registers, 0),
  7851.                              size)),
  7852.               copy_to_reg (struct_value_incoming_rtx));
  7853.       size += GET_MODE_SIZE (Pmode);
  7854.     }
  7855.  
  7856.   /* Return the address of the block.  */
  7857.   return copy_addr_to_reg (XEXP (registers, 0));
  7858. }
  7859.  
  7860. /* Perform an untyped call and save the state required to perform an
  7861.    untyped return of whatever value was returned by the given function.  */
  7862.  
  7863. static rtx
  7864. expand_builtin_apply (function, arguments, argsize)
  7865.      rtx function, arguments, argsize;
  7866. {
  7867.   int size, align, regno;
  7868.   enum machine_mode mode;
  7869.   rtx incoming_args, result, reg, dest, call_insn;
  7870.   rtx old_stack_level = 0;
  7871.   rtx call_fusage = 0;
  7872.  
  7873.   /* Create a block where the return registers can be saved.  */
  7874.   result = assign_stack_local (BLKmode, apply_result_size (), -1);
  7875.  
  7876.   /* ??? The argsize value should be adjusted here.  */
  7877.  
  7878.   /* Fetch the arg pointer from the ARGUMENTS block.  */
  7879.   incoming_args = gen_reg_rtx (Pmode);
  7880.   emit_move_insn (incoming_args,
  7881.           gen_rtx (MEM, Pmode, arguments));
  7882. #ifndef STACK_GROWS_DOWNWARD
  7883.   incoming_args = expand_binop (Pmode, sub_optab, incoming_args, argsize,
  7884.                 incoming_args, 0, OPTAB_LIB_WIDEN);
  7885. #endif
  7886.  
  7887.   /* Perform postincrements before actually calling the function.  */
  7888.   emit_queue ();
  7889.  
  7890.   /* Push a new argument block and copy the arguments.  */
  7891.   do_pending_stack_adjust ();
  7892.   emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  7893.  
  7894.   /* Push a block of memory onto the stack to store the memory arguments.
  7895.      Save the address in a register, and copy the memory arguments.  ??? I
  7896.      haven't figured out how the calling convention macros effect this,
  7897.      but it's likely that the source and/or destination addresses in
  7898.      the block copy will need updating in machine specific ways.  */
  7899.   dest = copy_addr_to_reg (push_block (argsize, 0, 0));
  7900.   emit_block_move (gen_rtx (MEM, BLKmode, dest),
  7901.            gen_rtx (MEM, BLKmode, incoming_args),
  7902.            argsize,
  7903.            PARM_BOUNDARY / BITS_PER_UNIT);
  7904.  
  7905.   /* Refer to the argument block.  */
  7906.   apply_args_size ();
  7907.   arguments = gen_rtx (MEM, BLKmode, arguments);
  7908.  
  7909.   /* Walk past the arg-pointer and structure value address.  */
  7910.   size = GET_MODE_SIZE (Pmode);
  7911.   if (struct_value_rtx)
  7912.     size += GET_MODE_SIZE (Pmode);
  7913.  
  7914.   /* Restore each of the registers previously saved.  Make USE insns
  7915.      for each of these registers for use in making the call.  */
  7916.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  7917.     if ((mode = apply_args_mode[regno]) != VOIDmode)
  7918.       {
  7919.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  7920.     if (size % align != 0)
  7921.       size = CEIL (size, align) * align;
  7922.     reg = gen_rtx (REG, mode, regno);
  7923.     emit_move_insn (reg,
  7924.             change_address (arguments, mode,
  7925.                     plus_constant (XEXP (arguments, 0),
  7926.                                size)));
  7927.  
  7928.     use_reg (&call_fusage, reg);
  7929.     size += GET_MODE_SIZE (mode);
  7930.       }
  7931.  
  7932.   /* Restore the structure value address unless this is passed as an
  7933.      "invisible" first argument.  */
  7934.   size = GET_MODE_SIZE (Pmode);
  7935.   if (struct_value_rtx)
  7936.     {
  7937.       rtx value = gen_reg_rtx (Pmode);
  7938.       emit_move_insn (value,
  7939.               change_address (arguments, Pmode,
  7940.                       plus_constant (XEXP (arguments, 0),
  7941.                              size)));
  7942.       emit_move_insn (struct_value_rtx, value);
  7943.       if (GET_CODE (struct_value_rtx) == REG)
  7944.       use_reg (&call_fusage, struct_value_rtx);
  7945.       size += GET_MODE_SIZE (Pmode);
  7946.     }
  7947.  
  7948.   /* All arguments and registers used for the call are set up by now!  */
  7949.   function = prepare_call_address (function, NULL_TREE, &call_fusage, 0);
  7950.  
  7951.   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
  7952.      and we don't want to load it into a register as an optimization,
  7953.      because prepare_call_address already did it if it should be done.  */
  7954.   if (GET_CODE (function) != SYMBOL_REF)
  7955.     function = memory_address (FUNCTION_MODE, function);
  7956.  
  7957.   /* Generate the actual call instruction and save the return value.  */
  7958. #ifdef HAVE_untyped_call
  7959.   if (HAVE_untyped_call)
  7960.     emit_call_insn (gen_untyped_call (gen_rtx (MEM, FUNCTION_MODE, function),
  7961.                       result, result_vector (1, result)));
  7962.   else
  7963. #endif
  7964. #ifdef HAVE_call_value
  7965.   if (HAVE_call_value)
  7966.     {
  7967.       rtx valreg = 0;
  7968.  
  7969.       /* Locate the unique return register.  It is not possible to
  7970.      express a call that sets more than one return register using
  7971.      call_value; use untyped_call for that.  In fact, untyped_call
  7972.      only needs to save the return registers in the given block.  */
  7973.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  7974.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  7975.       {
  7976.         if (valreg)
  7977.           abort (); /* HAVE_untyped_call required.  */
  7978.         valreg = gen_rtx (REG, mode, regno);
  7979.       }
  7980.  
  7981.       emit_call_insn (gen_call_value (valreg,
  7982.                       gen_rtx (MEM, FUNCTION_MODE, function),
  7983.                       const0_rtx, NULL_RTX, const0_rtx));
  7984.  
  7985.       emit_move_insn (change_address (result, GET_MODE (valreg),
  7986.                       XEXP (result, 0)),
  7987.               valreg);
  7988.     }
  7989.   else
  7990. #endif
  7991.     abort ();
  7992.  
  7993.   /* Find the CALL insn we just emitted.  */
  7994.   for (call_insn = get_last_insn ();
  7995.        call_insn && GET_CODE (call_insn) != CALL_INSN;
  7996.        call_insn = PREV_INSN (call_insn))
  7997.     ;
  7998.  
  7999.   if (! call_insn)
  8000.     abort ();
  8001.  
  8002.   /* Put the register usage information on the CALL.  If there is already
  8003.      some usage information, put ours at the end.  */
  8004.   if (CALL_INSN_FUNCTION_USAGE (call_insn))
  8005.     {
  8006.       rtx link;
  8007.  
  8008.       for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
  8009.        link = XEXP (link, 1))
  8010.     ;
  8011.  
  8012.       XEXP (link, 1) = call_fusage;
  8013.     }
  8014.   else
  8015.     CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
  8016.  
  8017.   /* Restore the stack.  */
  8018.   emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
  8019.  
  8020.   /* Return the address of the result block.  */
  8021.   return copy_addr_to_reg (XEXP (result, 0));
  8022. }
  8023.  
  8024. /* Perform an untyped return.  */
  8025.  
  8026. static void
  8027. expand_builtin_return (result)
  8028.      rtx result;
  8029. {
  8030.   int size, align, regno;
  8031.   enum machine_mode mode;
  8032.   rtx reg;
  8033.   rtx call_fusage = 0;
  8034.  
  8035.   apply_result_size ();
  8036.   result = gen_rtx (MEM, BLKmode, result);
  8037.  
  8038. #ifdef HAVE_untyped_return
  8039.   if (HAVE_untyped_return)
  8040.     {
  8041.       emit_jump_insn (gen_untyped_return (result, result_vector (0, result)));
  8042.       emit_barrier ();
  8043.       return;
  8044.     }
  8045. #endif
  8046.  
  8047.   /* Restore the return value and note that each value is used.  */
  8048.   size = 0;
  8049.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8050.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8051.       {
  8052.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8053.     if (size % align != 0)
  8054.       size = CEIL (size, align) * align;
  8055.     reg = gen_rtx (REG, mode, INCOMING_REGNO (regno));
  8056.     emit_move_insn (reg,
  8057.             change_address (result, mode,
  8058.                     plus_constant (XEXP (result, 0),
  8059.                                size)));
  8060.  
  8061.     push_to_sequence (call_fusage);
  8062.     emit_insn (gen_rtx (USE, VOIDmode, reg));
  8063.     call_fusage = get_insns ();
  8064.     end_sequence ();
  8065.     size += GET_MODE_SIZE (mode);
  8066.       }
  8067.  
  8068.   /* Put the USE insns before the return.  */
  8069.   emit_insns (call_fusage);
  8070.  
  8071.   /* Return whatever values was restored by jumping directly to the end
  8072.      of the function.  */
  8073.   expand_null_return ();
  8074. }
  8075.  
  8076. /* Expand code for a post- or pre- increment or decrement
  8077.    and return the RTX for the result.
  8078.    POST is 1 for postinc/decrements and 0 for preinc/decrements.  */
  8079.  
  8080. static rtx
  8081. expand_increment (exp, post)
  8082.      register tree exp;
  8083.      int post;
  8084. {
  8085.   register rtx op0, op1;
  8086.   register rtx temp, value;
  8087.   register tree incremented = TREE_OPERAND (exp, 0);
  8088.   optab this_optab = add_optab;
  8089.   int icode;
  8090.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
  8091.   int op0_is_copy = 0;
  8092.   int single_insn = 0;
  8093.   /* 1 means we can't store into OP0 directly,
  8094.      because it is a subreg narrower than a word,
  8095.      and we don't dare clobber the rest of the word.  */
  8096.   int bad_subreg = 0;
  8097.  
  8098.   if (output_bytecode)
  8099.     {
  8100.       bc_expand_expr (exp);
  8101.       return NULL_RTX;
  8102.     }
  8103.  
  8104.   /* Stabilize any component ref that might need to be
  8105.      evaluated more than once below.  */
  8106.   if (!post
  8107.       || TREE_CODE (incremented) == BIT_FIELD_REF
  8108.       || (TREE_CODE (incremented) == COMPONENT_REF
  8109.       && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
  8110.           || DECL_BIT_FIELD (TREE_OPERAND (incremented, 1)))))
  8111.     incremented = stabilize_reference (incremented);
  8112.   /* Nested *INCREMENT_EXPRs can happen in C++.  We must force innermost
  8113.      ones into save exprs so that they don't accidentally get evaluated
  8114.      more than once by the code below.  */
  8115.   if (TREE_CODE (incremented) == PREINCREMENT_EXPR
  8116.       || TREE_CODE (incremented) == PREDECREMENT_EXPR)
  8117.     incremented = save_expr (incremented);
  8118.  
  8119.   /* Compute the operands as RTX.
  8120.      Note whether OP0 is the actual lvalue or a copy of it:
  8121.      I believe it is a copy iff it is a register or subreg
  8122.      and insns were generated in computing it.   */
  8123.  
  8124.   temp = get_last_insn ();
  8125.   op0 = expand_expr (incremented, NULL_RTX, VOIDmode, 0);
  8126.  
  8127.   /* If OP0 is a SUBREG made for a promoted variable, we cannot increment
  8128.      in place but intead must do sign- or zero-extension during assignment,
  8129.      so we copy it into a new register and let the code below use it as
  8130.      a copy.
  8131.  
  8132.      Note that we can safely modify this SUBREG since it is know not to be
  8133.      shared (it was made by the expand_expr call above).  */
  8134.  
  8135.   if (GET_CODE (op0) == SUBREG && SUBREG_PROMOTED_VAR_P (op0))
  8136.     {
  8137.       if (post)
  8138.     SUBREG_REG (op0) = copy_to_reg (SUBREG_REG (op0));
  8139.       else
  8140.     bad_subreg = 1;
  8141.     }
  8142.   else if (GET_CODE (op0) == SUBREG
  8143.        && GET_MODE_BITSIZE (GET_MODE (op0)) < BITS_PER_WORD)
  8144.     {
  8145.       /* We cannot increment this SUBREG in place.  If we are
  8146.      post-incrementing, get a copy of the old value.  Otherwise,
  8147.      just mark that we cannot increment in place.  */
  8148.       if (post)
  8149.     op0 = copy_to_reg (op0);
  8150.       else
  8151.     bad_subreg = 1;
  8152.     }
  8153.  
  8154.   op0_is_copy = ((GET_CODE (op0) == SUBREG || GET_CODE (op0) == REG)
  8155.          && temp != get_last_insn ());
  8156.   op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  8157.  
  8158.   /* Decide whether incrementing or decrementing.  */
  8159.   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
  8160.       || TREE_CODE (exp) == PREDECREMENT_EXPR)
  8161.     this_optab = sub_optab;
  8162.  
  8163.   /* Convert decrement by a constant into a negative increment.  */
  8164.   if (this_optab == sub_optab
  8165.       && GET_CODE (op1) == CONST_INT)
  8166.     {
  8167.       op1 = GEN_INT (- INTVAL (op1));
  8168.       this_optab = add_optab;
  8169.     }
  8170.  
  8171.   /* For a preincrement, see if we can do this with a single instruction.  */
  8172.   if (!post)
  8173.     {
  8174.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  8175.       if (icode != (int) CODE_FOR_nothing
  8176.       /* Make sure that OP0 is valid for operands 0 and 1
  8177.          of the insn we want to queue.  */
  8178.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  8179.       && (*insn_operand_predicate[icode][1]) (op0, mode)
  8180.       && (*insn_operand_predicate[icode][2]) (op1, mode))
  8181.     single_insn = 1;
  8182.     }
  8183.  
  8184.   /* If OP0 is not the actual lvalue, but rather a copy in a register,
  8185.      then we cannot just increment OP0.  We must therefore contrive to
  8186.      increment the original value.  Then, for postincrement, we can return
  8187.      OP0 since it is a copy of the old value.  For preincrement, expand here
  8188.      unless we can do it with a single insn.
  8189.  
  8190.      Likewise if storing directly into OP0 would clobber high bits
  8191.      we need to preserve (bad_subreg).  */
  8192.   if (op0_is_copy || (!post && !single_insn) || bad_subreg)
  8193.     {
  8194.       /* This is the easiest way to increment the value wherever it is.
  8195.      Problems with multiple evaluation of INCREMENTED are prevented
  8196.      because either (1) it is a component_ref or preincrement,
  8197.      in which case it was stabilized above, or (2) it is an array_ref
  8198.      with constant index in an array in a register, which is
  8199.      safe to reevaluate.  */
  8200.       tree newexp = build (((TREE_CODE (exp) == POSTDECREMENT_EXPR
  8201.                  || TREE_CODE (exp) == PREDECREMENT_EXPR)
  8202.                 ? MINUS_EXPR : PLUS_EXPR),
  8203.                TREE_TYPE (exp),
  8204.                incremented,
  8205.                TREE_OPERAND (exp, 1));
  8206.       temp = expand_assignment (incremented, newexp, ! post, 0);
  8207.       return post ? op0 : temp;
  8208.     }
  8209.  
  8210.   if (post)
  8211.     {
  8212.       /* We have a true reference to the value in OP0.
  8213.      If there is an insn to add or subtract in this mode, queue it.
  8214.      Queueing the increment insn avoids the register shuffling
  8215.      that often results if we must increment now and first save
  8216.      the old value for subsequent use.  */
  8217.  
  8218. #if 0  /* Turned off to avoid making extra insn for indexed memref.  */
  8219.       op0 = stabilize (op0);
  8220. #endif
  8221.  
  8222.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  8223.       if (icode != (int) CODE_FOR_nothing
  8224.       /* Make sure that OP0 is valid for operands 0 and 1
  8225.          of the insn we want to queue.  */
  8226.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  8227.       && (*insn_operand_predicate[icode][1]) (op0, mode))
  8228.     {
  8229.       if (! (*insn_operand_predicate[icode][2]) (op1, mode))
  8230.         op1 = force_reg (mode, op1);
  8231.  
  8232.       return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
  8233.     }
  8234.     }
  8235.  
  8236.   /* Preincrement, or we can't increment with one simple insn.  */
  8237.   if (post)
  8238.     /* Save a copy of the value before inc or dec, to return it later.  */
  8239.     temp = value = copy_to_reg (op0);
  8240.   else
  8241.     /* Arrange to return the incremented value.  */
  8242.     /* Copy the rtx because expand_binop will protect from the queue,
  8243.        and the results of that would be invalid for us to return
  8244.        if our caller does emit_queue before using our result.  */
  8245.     temp = copy_rtx (value = op0);
  8246.  
  8247.   /* Increment however we can.  */
  8248.   op1 = expand_binop (mode, this_optab, value, op1, op0,
  8249.               TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  8250.   /* Make sure the value is stored into OP0.  */
  8251.   if (op1 != op0)
  8252.     emit_move_insn (op0, op1);
  8253.  
  8254.   return temp;
  8255. }
  8256.  
  8257. /* Expand all function calls contained within EXP, innermost ones first.
  8258.    But don't look within expressions that have sequence points.
  8259.    For each CALL_EXPR, record the rtx for its value
  8260.    in the CALL_EXPR_RTL field.  */
  8261.  
  8262. static void
  8263. preexpand_calls (exp)
  8264.      tree exp;
  8265. {
  8266.   register int nops, i;
  8267.   int type = TREE_CODE_CLASS (TREE_CODE (exp));
  8268.  
  8269.   if (! do_preexpand_calls)
  8270.     return;
  8271.  
  8272.   /* Only expressions and references can contain calls.  */
  8273.  
  8274.   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r')
  8275.     return;
  8276.  
  8277.   switch (TREE_CODE (exp))
  8278.     {
  8279.     case CALL_EXPR:
  8280.       /* Do nothing if already expanded.  */
  8281.       if (CALL_EXPR_RTL (exp) != 0)
  8282.     return;
  8283.  
  8284.       /* Do nothing to built-in functions.  */
  8285.       if (TREE_CODE (TREE_OPERAND (exp, 0)) != ADDR_EXPR
  8286.       || TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != FUNCTION_DECL
  8287.       || ! DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  8288.     CALL_EXPR_RTL (exp) = expand_call (exp, NULL_RTX, 0);
  8289.       return;
  8290.  
  8291.     case COMPOUND_EXPR:
  8292.     case COND_EXPR:
  8293.     case TRUTH_ANDIF_EXPR:
  8294.     case TRUTH_ORIF_EXPR:
  8295.       /* If we find one of these, then we can be sure
  8296.      the adjust will be done for it (since it makes jumps).
  8297.      Do it now, so that if this is inside an argument
  8298.      of a function, we don't get the stack adjustment
  8299.      after some other args have already been pushed.  */
  8300.       do_pending_stack_adjust ();
  8301.       return;
  8302.  
  8303.     case BLOCK:
  8304.     case RTL_EXPR:
  8305.     case WITH_CLEANUP_EXPR:
  8306.       return;
  8307.  
  8308.     case SAVE_EXPR:
  8309.       if (SAVE_EXPR_RTL (exp) != 0)
  8310.     return;
  8311.     }
  8312.  
  8313.   nops = tree_code_length[(int) TREE_CODE (exp)];
  8314.   for (i = 0; i < nops; i++)
  8315.     if (TREE_OPERAND (exp, i) != 0)
  8316.       {
  8317.     type = TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, i)));
  8318.     if (type == 'e' || type == '<' || type == '1' || type == '2'
  8319.         || type == 'r')
  8320.       preexpand_calls (TREE_OPERAND (exp, i));
  8321.       }
  8322. }
  8323.  
  8324. /* At the start of a function, record that we have no previously-pushed
  8325.    arguments waiting to be popped.  */
  8326.  
  8327. void
  8328. init_pending_stack_adjust ()
  8329. {
  8330.   pending_stack_adjust = 0;
  8331. }
  8332.  
  8333. /* When exiting from function, if safe, clear out any pending stack adjust
  8334.    so the adjustment won't get done.  */
  8335.  
  8336. void
  8337. clear_pending_stack_adjust ()
  8338. {
  8339. #ifdef EXIT_IGNORE_STACK
  8340.   if (! flag_omit_frame_pointer && EXIT_IGNORE_STACK
  8341.       && ! (DECL_INLINE (current_function_decl) && ! flag_no_inline)
  8342.       && ! flag_inline_functions)
  8343.     pending_stack_adjust = 0;
  8344. #endif
  8345. }
  8346.  
  8347. /* Pop any previously-pushed arguments that have not been popped yet.  */
  8348.  
  8349. void
  8350. do_pending_stack_adjust ()
  8351. {
  8352.   if (inhibit_defer_pop == 0)
  8353.     {
  8354.       if (pending_stack_adjust != 0)
  8355.     adjust_stack (GEN_INT (pending_stack_adjust));
  8356.       pending_stack_adjust = 0;
  8357.     }
  8358. }
  8359.  
  8360. /* Defer the expansion all cleanups up to OLD_CLEANUPS.
  8361.    Returns the cleanups to be performed.  */
  8362.  
  8363. static tree
  8364. defer_cleanups_to (old_cleanups)
  8365.      tree old_cleanups;
  8366. {
  8367.   tree new_cleanups = NULL_TREE;
  8368.   tree cleanups = cleanups_this_call;
  8369.   tree last = NULL_TREE;
  8370.  
  8371.   while (cleanups_this_call != old_cleanups)
  8372.     {
  8373.       (*interim_eh_hook) (TREE_VALUE (cleanups_this_call));
  8374.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  8375.     }      
  8376.  
  8377.   if (last)
  8378.     {
  8379.       /* Remove the list from the chain of cleanups.  */
  8380.       TREE_CHAIN (last) = NULL_TREE;
  8381.  
  8382.       /* reverse them so that we can build them in the right order.  */
  8383.       cleanups = nreverse (cleanups);
  8384.  
  8385.       while (cleanups)
  8386.     {
  8387.       if (new_cleanups)
  8388.         new_cleanups = build (COMPOUND_EXPR, TREE_TYPE (new_cleanups),
  8389.                   TREE_VALUE (cleanups), new_cleanups);
  8390.       else
  8391.         new_cleanups = TREE_VALUE (cleanups);
  8392.  
  8393.       cleanups = TREE_CHAIN (cleanups);
  8394.     }
  8395.     }
  8396.  
  8397.   return new_cleanups;
  8398. }
  8399.  
  8400. /* Expand all cleanups up to OLD_CLEANUPS.
  8401.    Needed here, and also for language-dependent calls.  */
  8402.  
  8403. void
  8404. expand_cleanups_to (old_cleanups)
  8405.      tree old_cleanups;
  8406. {
  8407.   while (cleanups_this_call != old_cleanups)
  8408.     {
  8409.       (*interim_eh_hook) (TREE_VALUE (cleanups_this_call));
  8410.       expand_expr (TREE_VALUE (cleanups_this_call), const0_rtx, VOIDmode, 0);
  8411.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  8412.     }
  8413. }
  8414.  
  8415. /* Expand conditional expressions.  */
  8416.  
  8417. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  8418.    LABEL is an rtx of code CODE_LABEL, in this function and all the
  8419.    functions here.  */
  8420.  
  8421. void
  8422. jumpifnot (exp, label)
  8423.      tree exp;
  8424.      rtx label;
  8425. {
  8426.   do_jump (exp, label, NULL_RTX);
  8427. }
  8428.  
  8429. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero.  */
  8430.  
  8431. void
  8432. jumpif (exp, label)
  8433.      tree exp;
  8434.      rtx label;
  8435. {
  8436.   do_jump (exp, NULL_RTX, label);
  8437. }
  8438.  
  8439. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  8440.    the result is zero, or IF_TRUE_LABEL if the result is one.
  8441.    Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  8442.    meaning fall through in that case.
  8443.  
  8444.    do_jump always does any pending stack adjust except when it does not
  8445.    actually perform a jump.  An example where there is no jump
  8446.    is when EXP is `(foo (), 0)' and IF_FALSE_LABEL is null.
  8447.  
  8448.    This function is responsible for optimizing cases such as
  8449.    &&, || and comparison operators in EXP.  */
  8450.  
  8451. void
  8452. do_jump (exp, if_false_label, if_true_label)
  8453.      tree exp;
  8454.      rtx if_false_label, if_true_label;
  8455. {
  8456.   register enum tree_code code = TREE_CODE (exp);
  8457.   /* Some cases need to create a label to jump to
  8458.      in order to properly fall through.
  8459.      These cases set DROP_THROUGH_LABEL nonzero.  */
  8460.   rtx drop_through_label = 0;
  8461.   rtx temp;
  8462.   rtx comparison = 0;
  8463.   int i;
  8464.   tree type;
  8465.   enum machine_mode mode;
  8466.  
  8467.   emit_queue ();
  8468.  
  8469.   switch (code)
  8470.     {
  8471.     case ERROR_MARK:
  8472.       break;
  8473.  
  8474.     case INTEGER_CST:
  8475.       temp = integer_zerop (exp) ? if_false_label : if_true_label;
  8476.       if (temp)
  8477.     emit_jump (temp);
  8478.       break;
  8479.  
  8480. #if 0
  8481.       /* This is not true with #pragma weak  */
  8482.     case ADDR_EXPR:
  8483.       /* The address of something can never be zero.  */
  8484.       if (if_true_label)
  8485.     emit_jump (if_true_label);
  8486.       break;
  8487. #endif
  8488.  
  8489.     case NOP_EXPR:
  8490.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
  8491.       || TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
  8492.       || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF)
  8493.     goto normal;
  8494.     case CONVERT_EXPR:
  8495.       /* If we are narrowing the operand, we have to do the compare in the
  8496.      narrower mode.  */
  8497.       if ((TYPE_PRECISION (TREE_TYPE (exp))
  8498.        < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8499.     goto normal;
  8500.     case NON_LVALUE_EXPR:
  8501.     case REFERENCE_EXPR:
  8502.     case ABS_EXPR:
  8503.     case NEGATE_EXPR:
  8504.     case LROTATE_EXPR:
  8505.     case RROTATE_EXPR:
  8506.       /* These cannot change zero->non-zero or vice versa.  */
  8507.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  8508.       break;
  8509.  
  8510. #if 0
  8511.       /* This is never less insns than evaluating the PLUS_EXPR followed by
  8512.      a test and can be longer if the test is eliminated.  */
  8513.     case PLUS_EXPR:
  8514.       /* Reduce to minus.  */
  8515.       exp = build (MINUS_EXPR, TREE_TYPE (exp),
  8516.            TREE_OPERAND (exp, 0),
  8517.            fold (build1 (NEGATE_EXPR, TREE_TYPE (TREE_OPERAND (exp, 1)),
  8518.                  TREE_OPERAND (exp, 1))));
  8519.       /* Process as MINUS.  */
  8520. #endif
  8521.  
  8522.     case MINUS_EXPR:
  8523.       /* Non-zero iff operands of minus differ.  */
  8524.       comparison = compare (build (NE_EXPR, TREE_TYPE (exp),
  8525.                    TREE_OPERAND (exp, 0),
  8526.                    TREE_OPERAND (exp, 1)),
  8527.                 NE, NE);
  8528.       break;
  8529.  
  8530.     case BIT_AND_EXPR:
  8531.       /* If we are AND'ing with a small constant, do this comparison in the
  8532.      smallest type that fits.  If the machine doesn't have comparisons
  8533.      that small, it will be converted back to the wider comparison.
  8534.      This helps if we are testing the sign bit of a narrower object.
  8535.      combine can't do this for us because it can't know whether a
  8536.      ZERO_EXTRACT or a compare in a smaller mode exists, but we do.  */
  8537.  
  8538.       if (! SLOW_BYTE_ACCESS
  8539.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  8540.       && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT
  8541.       && (i = floor_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))) >= 0
  8542.       && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode
  8543.       && (type = type_for_mode (mode, 1)) != 0
  8544.       && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  8545.       && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code
  8546.           != CODE_FOR_nothing))
  8547.     {
  8548.       do_jump (convert (type, exp), if_false_label, if_true_label);
  8549.       break;
  8550.     }
  8551.       goto normal;
  8552.  
  8553.     case TRUTH_NOT_EXPR:
  8554.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  8555.       break;
  8556.  
  8557.     case TRUTH_ANDIF_EXPR:
  8558.       if (if_false_label == 0)
  8559.     if_false_label = drop_through_label = gen_label_rtx ();
  8560.       do_jump (TREE_OPERAND (exp, 0), if_false_label, NULL_RTX);
  8561.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  8562.       break;
  8563.  
  8564.     case TRUTH_ORIF_EXPR:
  8565.       if (if_true_label == 0)
  8566.     if_true_label = drop_through_label = gen_label_rtx ();
  8567.       do_jump (TREE_OPERAND (exp, 0), NULL_RTX, if_true_label);
  8568.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  8569.       break;
  8570.  
  8571.     case COMPOUND_EXPR:
  8572.       push_temp_slots ();
  8573.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  8574.       free_temp_slots ();
  8575.       pop_temp_slots ();
  8576.       emit_queue ();
  8577.       do_pending_stack_adjust ();
  8578.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  8579.       break;
  8580.  
  8581.     case COMPONENT_REF:
  8582.     case BIT_FIELD_REF:
  8583.     case ARRAY_REF:
  8584.       {
  8585.     int bitsize, bitpos, unsignedp;
  8586.     enum machine_mode mode;
  8587.     tree type;
  8588.     tree offset;
  8589.     int volatilep = 0;
  8590.  
  8591.     /* Get description of this reference.  We don't actually care
  8592.        about the underlying object here.  */
  8593.     get_inner_reference (exp, &bitsize, &bitpos, &offset,
  8594.                  &mode, &unsignedp, &volatilep);
  8595.  
  8596.     type = type_for_size (bitsize, unsignedp);
  8597.     if (! SLOW_BYTE_ACCESS
  8598.         && type != 0 && bitsize >= 0
  8599.         && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  8600.         && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code
  8601.         != CODE_FOR_nothing))
  8602.       {
  8603.         do_jump (convert (type, exp), if_false_label, if_true_label);
  8604.         break;
  8605.       }
  8606.     goto normal;
  8607.       }
  8608.  
  8609.     case COND_EXPR:
  8610.       /* Do (a ? 1 : 0) and (a ? 0 : 1) as special cases.  */
  8611.       if (integer_onep (TREE_OPERAND (exp, 1))
  8612.       && integer_zerop (TREE_OPERAND (exp, 2)))
  8613.     do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  8614.  
  8615.       else if (integer_zerop (TREE_OPERAND (exp, 1))
  8616.            && integer_onep (TREE_OPERAND (exp, 2)))
  8617.     do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  8618.  
  8619.       else
  8620.     {
  8621.       register rtx label1 = gen_label_rtx ();
  8622.       drop_through_label = gen_label_rtx ();
  8623.       do_jump (TREE_OPERAND (exp, 0), label1, NULL_RTX);
  8624.       /* Now the THEN-expression.  */
  8625.       do_jump (TREE_OPERAND (exp, 1),
  8626.            if_false_label ? if_false_label : drop_through_label,
  8627.            if_true_label ? if_true_label : drop_through_label);
  8628.       /* In case the do_jump just above never jumps.  */
  8629.       do_pending_stack_adjust ();
  8630.       emit_label (label1);
  8631.       /* Now the ELSE-expression.  */
  8632.       do_jump (TREE_OPERAND (exp, 2),
  8633.            if_false_label ? if_false_label : drop_through_label,
  8634.            if_true_label ? if_true_label : drop_through_label);
  8635.     }
  8636.       break;
  8637.  
  8638.     case EQ_EXPR:
  8639.       if (integer_zerop (TREE_OPERAND (exp, 1)))
  8640.     do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  8641.       else if (((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  8642.          == MODE_INT)
  8643.         && 
  8644.         !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8645.            || GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))) == MODE_COMPLEX_FLOAT
  8646.            || GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))) == MODE_COMPLEX_INT)
  8647.     do_jump_by_parts_equality (exp, if_false_label, if_true_label);
  8648.       else
  8649.     comparison = compare (exp, EQ, EQ);
  8650.       break;
  8651.  
  8652.     case NE_EXPR:
  8653.       if (integer_zerop (TREE_OPERAND (exp, 1)))
  8654.     do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  8655.       else if (((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  8656.          == MODE_INT)
  8657.         && 
  8658.         !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8659.            || GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))) == MODE_COMPLEX_FLOAT
  8660.            || GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))) == MODE_COMPLEX_INT)
  8661.     do_jump_by_parts_equality (exp, if_true_label, if_false_label);
  8662.       else
  8663.     comparison = compare (exp, NE, NE);
  8664.       break;
  8665.  
  8666.     case LT_EXPR:
  8667.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  8668.        == MODE_INT)
  8669.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8670.     do_jump_by_parts_greater (exp, 1, if_false_label, if_true_label);
  8671.       else
  8672.     comparison = compare (exp, LT, LTU);
  8673.       break;
  8674.  
  8675.     case LE_EXPR:
  8676.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  8677.        == MODE_INT)
  8678.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8679.     do_jump_by_parts_greater (exp, 0, if_true_label, if_false_label);
  8680.       else
  8681.     comparison = compare (exp, LE, LEU);
  8682.       break;
  8683.  
  8684.     case GT_EXPR:
  8685.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  8686.        == MODE_INT)
  8687.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8688.     do_jump_by_parts_greater (exp, 0, if_false_label, if_true_label);
  8689.       else
  8690.     comparison = compare (exp, GT, GTU);
  8691.       break;
  8692.  
  8693.     case GE_EXPR:
  8694.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  8695.        == MODE_INT)
  8696.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8697.     do_jump_by_parts_greater (exp, 1, if_true_label, if_false_label);
  8698.       else
  8699.     comparison = compare (exp, GE, GEU);
  8700.       break;
  8701.  
  8702.     default:
  8703.     normal:
  8704.       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  8705. #if 0
  8706.       /* This is not needed any more and causes poor code since it causes
  8707.      comparisons and tests from non-SI objects to have different code
  8708.      sequences.  */
  8709.       /* Copy to register to avoid generating bad insns by cse
  8710.      from (set (mem ...) (arithop))  (set (cc0) (mem ...)).  */
  8711.       if (!cse_not_expected && GET_CODE (temp) == MEM)
  8712.     temp = copy_to_reg (temp);
  8713. #endif
  8714.       do_pending_stack_adjust ();
  8715.       if (GET_CODE (temp) == CONST_INT)
  8716.     comparison = (temp == const0_rtx ? const0_rtx : const_true_rtx);
  8717.       else if (GET_CODE (temp) == LABEL_REF)
  8718.     comparison = const_true_rtx;
  8719.       else if (GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT
  8720.            && !can_compare_p (GET_MODE (temp)))
  8721.     /* Note swapping the labels gives us not-equal.  */
  8722.     do_jump_by_parts_equality_rtx (temp, if_true_label, if_false_label);
  8723.       else if (GET_MODE (temp) != VOIDmode)
  8724.     comparison = compare_from_rtx (temp, CONST0_RTX (GET_MODE (temp)),
  8725.                        NE, TREE_UNSIGNED (TREE_TYPE (exp)),
  8726.                        GET_MODE (temp), NULL_RTX, 0);
  8727.       else
  8728.     abort ();
  8729.     }
  8730.  
  8731.   /* Do any postincrements in the expression that was tested.  */
  8732.   emit_queue ();
  8733.  
  8734.   /* If COMPARISON is nonzero here, it is an rtx that can be substituted
  8735.      straight into a conditional jump instruction as the jump condition.
  8736.      Otherwise, all the work has been done already.  */
  8737.  
  8738.   if (comparison == const_true_rtx)
  8739.     {
  8740.       if (if_true_label)
  8741.     emit_jump (if_true_label);
  8742.     }
  8743.   else if (comparison == const0_rtx)
  8744.     {
  8745.       if (if_false_label)
  8746.     emit_jump (if_false_label);
  8747.     }
  8748.   else if (comparison)
  8749.     do_jump_for_compare (comparison, if_false_label, if_true_label);
  8750.  
  8751.   if (drop_through_label)
  8752.     {
  8753.       /* If do_jump produces code that might be jumped around,
  8754.      do any stack adjusts from that code, before the place
  8755.      where control merges in.  */
  8756.       do_pending_stack_adjust ();
  8757.       emit_label (drop_through_label);
  8758.     }
  8759. }
  8760.  
  8761. /* Given a comparison expression EXP for values too wide to be compared
  8762.    with one insn, test the comparison and jump to the appropriate label.
  8763.    The code of EXP is ignored; we always test GT if SWAP is 0,
  8764.    and LT if SWAP is 1.  */
  8765.  
  8766. static void
  8767. do_jump_by_parts_greater (exp, swap, if_false_label, if_true_label)
  8768.      tree exp;
  8769.      int swap;
  8770.      rtx if_false_label, if_true_label;
  8771. {
  8772.   rtx op0 = expand_expr (TREE_OPERAND (exp, swap), NULL_RTX, VOIDmode, 0);
  8773.   rtx op1 = expand_expr (TREE_OPERAND (exp, !swap), NULL_RTX, VOIDmode, 0);
  8774.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  8775.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  8776.   rtx drop_through_label = 0;
  8777.   int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
  8778.   int i;
  8779.  
  8780.   if (! if_true_label || ! if_false_label)
  8781.     drop_through_label = gen_label_rtx ();
  8782.   if (! if_true_label)
  8783.     if_true_label = drop_through_label;
  8784.   if (! if_false_label)
  8785.     if_false_label = drop_through_label;
  8786.  
  8787.   /* Compare a word at a time, high order first.  */
  8788.   for (i = 0; i < nwords; i++)
  8789.     {
  8790.       rtx comp;
  8791.       rtx op0_word, op1_word;
  8792.  
  8793.       if (WORDS_BIG_ENDIAN)
  8794.     {
  8795.       op0_word = operand_subword_force (op0, i, mode);
  8796.       op1_word = operand_subword_force (op1, i, mode);
  8797.     }
  8798.       else
  8799.     {
  8800.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  8801.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  8802.     }
  8803.  
  8804.       /* All but high-order word must be compared as unsigned.  */
  8805.       comp = compare_from_rtx (op0_word, op1_word,
  8806.                    (unsignedp || i > 0) ? GTU : GT,
  8807.                    unsignedp, word_mode, NULL_RTX, 0);
  8808.       if (comp == const_true_rtx)
  8809.     emit_jump (if_true_label);
  8810.       else if (comp != const0_rtx)
  8811.     do_jump_for_compare (comp, NULL_RTX, if_true_label);
  8812.  
  8813.       /* Consider lower words only if these are equal.  */
  8814.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, word_mode,
  8815.                    NULL_RTX, 0);
  8816.       if (comp == const_true_rtx)
  8817.     emit_jump (if_false_label);
  8818.       else if (comp != const0_rtx)
  8819.     do_jump_for_compare (comp, NULL_RTX, if_false_label);
  8820.     }
  8821.  
  8822.   if (if_false_label)
  8823.     emit_jump (if_false_label);
  8824.   if (drop_through_label)
  8825.     emit_label (drop_through_label);
  8826. }
  8827.  
  8828. /* Compare OP0 with OP1, word at a time, in mode MODE.
  8829.    UNSIGNEDP says to do unsigned comparison.
  8830.    Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise.  */
  8831.  
  8832. static void
  8833. do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label, if_true_label)
  8834.      enum machine_mode mode;
  8835.      int unsignedp;
  8836.      rtx op0, op1;
  8837.      rtx if_false_label, if_true_label;
  8838. {
  8839.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  8840.   rtx drop_through_label = 0;
  8841.   int i;
  8842.  
  8843.   if (! if_true_label || ! if_false_label)
  8844.     drop_through_label = gen_label_rtx ();
  8845.   if (! if_true_label)
  8846.     if_true_label = drop_through_label;
  8847.   if (! if_false_label)
  8848.     if_false_label = drop_through_label;
  8849.  
  8850.   /* Compare a word at a time, high order first.  */
  8851.   for (i = 0; i < nwords; i++)
  8852.     {
  8853.       rtx comp;
  8854.       rtx op0_word, op1_word;
  8855.  
  8856.       if (WORDS_BIG_ENDIAN)
  8857.     {
  8858.       op0_word = operand_subword_force (op0, i, mode);
  8859.       op1_word = operand_subword_force (op1, i, mode);
  8860.     }
  8861.       else
  8862.     {
  8863.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  8864.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  8865.     }
  8866.  
  8867.       /* All but high-order word must be compared as unsigned.  */
  8868.       comp = compare_from_rtx (op0_word, op1_word,
  8869.                    (unsignedp || i > 0) ? GTU : GT,
  8870.                    unsignedp, word_mode, NULL_RTX, 0);
  8871.       if (comp == const_true_rtx)
  8872.     emit_jump (if_true_label);
  8873.       else if (comp != const0_rtx)
  8874.     do_jump_for_compare (comp, NULL_RTX, if_true_label);
  8875.  
  8876.       /* Consider lower words only if these are equal.  */
  8877.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, word_mode,
  8878.                    NULL_RTX, 0);
  8879.       if (comp == const_true_rtx)
  8880.     emit_jump (if_false_label);
  8881.       else if (comp != const0_rtx)
  8882.     do_jump_for_compare (comp, NULL_RTX, if_false_label);
  8883.     }
  8884.  
  8885.   if (if_false_label)
  8886.     emit_jump (if_false_label);
  8887.   if (drop_through_label)
  8888.     emit_label (drop_through_label);
  8889. }
  8890.  
  8891. /* Given an EQ_EXPR expression EXP for values too wide to be compared
  8892.    with one insn, test the comparison and jump to the appropriate label.  */
  8893.  
  8894. static void
  8895. do_jump_by_parts_equality (exp, if_false_label, if_true_label)
  8896.      tree exp;
  8897.      rtx if_false_label, if_true_label;
  8898. {
  8899.   rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  8900.   rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  8901.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  8902.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  8903.   int i;
  8904.   rtx drop_through_label = 0;
  8905.  
  8906.   if (! if_false_label)
  8907.     drop_through_label = if_false_label = gen_label_rtx ();
  8908.  
  8909.   for (i = 0; i < nwords; i++)
  8910.     {
  8911.       rtx comp = compare_from_rtx (operand_subword_force (op0, i, mode),
  8912.                    operand_subword_force (op1, i, mode),
  8913.                    EQ, TREE_UNSIGNED (TREE_TYPE (exp)),
  8914.                    word_mode, NULL_RTX, 0);
  8915.       if (comp == const_true_rtx)
  8916.     emit_jump (if_false_label);
  8917.       else if (comp != const0_rtx)
  8918.     do_jump_for_compare (comp, if_false_label, NULL_RTX);
  8919.     }
  8920.  
  8921.   if (if_true_label)
  8922.     emit_jump (if_true_label);
  8923.   if (drop_through_label)
  8924.     emit_label (drop_through_label);
  8925. }
  8926.  
  8927. /* Jump according to whether OP0 is 0.
  8928.    We assume that OP0 has an integer mode that is too wide
  8929.    for the available compare insns.  */
  8930.  
  8931. static void
  8932. do_jump_by_parts_equality_rtx (op0, if_false_label, if_true_label)
  8933.      rtx op0;
  8934.      rtx if_false_label, if_true_label;
  8935. {
  8936.   int nwords = GET_MODE_SIZE (GET_MODE (op0)) / UNITS_PER_WORD;
  8937.   int i;
  8938.   rtx drop_through_label = 0;
  8939.  
  8940.   if (! if_false_label)
  8941.     drop_through_label = if_false_label = gen_label_rtx ();
  8942.  
  8943.   for (i = 0; i < nwords; i++)
  8944.     {
  8945.       rtx comp = compare_from_rtx (operand_subword_force (op0, i,
  8946.                               GET_MODE (op0)),
  8947.                    const0_rtx, EQ, 1, word_mode, NULL_RTX, 0);
  8948.       if (comp == const_true_rtx)
  8949.     emit_jump (if_false_label);
  8950.       else if (comp != const0_rtx)
  8951.     do_jump_for_compare (comp, if_false_label, NULL_RTX);
  8952.     }
  8953.  
  8954.   if (if_true_label)
  8955.     emit_jump (if_true_label);
  8956.   if (drop_through_label)
  8957.     emit_label (drop_through_label);
  8958. }
  8959.  
  8960. /* Given a comparison expression in rtl form, output conditional branches to
  8961.    IF_TRUE_LABEL, IF_FALSE_LABEL, or both.  */
  8962.  
  8963. static void
  8964. do_jump_for_compare (comparison, if_false_label, if_true_label)
  8965.      rtx comparison, if_false_label, if_true_label;
  8966. {
  8967.   if (if_true_label)
  8968.     {
  8969.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  8970.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
  8971.       else
  8972.     abort ();
  8973.  
  8974.       if (if_false_label)
  8975.     emit_jump (if_false_label);
  8976.     }
  8977.   else if (if_false_label)
  8978.     {
  8979.       rtx insn;
  8980.       rtx prev = get_last_insn ();
  8981.       rtx branch = 0;
  8982.  
  8983.       if (prev != 0)
  8984.     prev = PREV_INSN (prev);
  8985.  
  8986.       /* Output the branch with the opposite condition.  Then try to invert
  8987.      what is generated.  If more than one insn is a branch, or if the
  8988.      branch is not the last insn written, abort. If we can't invert
  8989.      the branch, emit make a true label, redirect this jump to that,
  8990.      emit a jump to the false label and define the true label.  */
  8991.  
  8992.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  8993.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_false_label));
  8994.       else
  8995.     abort ();
  8996.  
  8997.       /* Here we get the insn before what was just emitted.
  8998.      On some machines, emitting the branch can discard
  8999.      the previous compare insn and emit a replacement.  */
  9000.       if (prev == 0)
  9001.     /* If there's only one preceding insn...  */
  9002.     insn = get_insns ();
  9003.       else
  9004.     insn = NEXT_INSN (prev);
  9005.  
  9006.       for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn))
  9007.     if (GET_CODE (insn) == JUMP_INSN)
  9008.       {
  9009.         if (branch)
  9010.           abort ();
  9011.         branch = insn;
  9012.       }
  9013.  
  9014.       if (branch != get_last_insn ())
  9015.     abort ();
  9016.  
  9017.       JUMP_LABEL (branch) = if_false_label;
  9018.       if (! invert_jump (branch, if_false_label))
  9019.     {
  9020.       if_true_label = gen_label_rtx ();
  9021.       redirect_jump (branch, if_true_label);
  9022.       emit_jump (if_false_label);
  9023.       emit_label (if_true_label);
  9024.     }
  9025.     }
  9026. }
  9027.  
  9028. /* Generate code for a comparison expression EXP
  9029.    (including code to compute the values to be compared)
  9030.    and set (CC0) according to the result.
  9031.    SIGNED_CODE should be the rtx operation for this comparison for
  9032.    signed data; UNSIGNED_CODE, likewise for use if data is unsigned.
  9033.  
  9034.    We force a stack adjustment unless there are currently
  9035.    things pushed on the stack that aren't yet used.  */
  9036.  
  9037. static rtx
  9038. compare (exp, signed_code, unsigned_code)
  9039.      register tree exp;
  9040.      enum rtx_code signed_code, unsigned_code;
  9041. {
  9042.   register rtx op0
  9043.     = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  9044.   register rtx op1
  9045.     = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  9046.   register tree type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9047.   register enum machine_mode mode = TYPE_MODE (type);
  9048.   int unsignedp = TREE_UNSIGNED (type);
  9049.   enum rtx_code code = unsignedp ? unsigned_code : signed_code;
  9050.  
  9051.   return compare_from_rtx (op0, op1, code, unsignedp, mode,
  9052.                ((mode == BLKmode)
  9053.                 ? expr_size (TREE_OPERAND (exp, 0)) : NULL_RTX),
  9054.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  9055. }
  9056.  
  9057. /* Like compare but expects the values to compare as two rtx's.
  9058.    The decision as to signed or unsigned comparison must be made by the caller.
  9059.  
  9060.    If MODE is BLKmode, SIZE is an RTX giving the size of the objects being
  9061.    compared.
  9062.  
  9063.    If ALIGN is non-zero, it is the alignment of this type; if zero, the
  9064.    size of MODE should be used.  */
  9065.  
  9066. rtx
  9067. compare_from_rtx (op0, op1, code, unsignedp, mode, size, align)
  9068.      register rtx op0, op1;
  9069.      enum rtx_code code;
  9070.      int unsignedp;
  9071.      enum machine_mode mode;
  9072.      rtx size;
  9073.      int align;
  9074. {
  9075.   rtx tem;
  9076.  
  9077.   /* If one operand is constant, make it the second one.  Only do this
  9078.      if the other operand is not constant as well.  */
  9079.  
  9080.   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
  9081.       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
  9082.     {
  9083.       tem = op0;
  9084.       op0 = op1;
  9085.       op1 = tem;
  9086.       code = swap_condition (code);
  9087.     }
  9088.  
  9089.   if (flag_force_mem)
  9090.     {
  9091.       op0 = force_not_mem (op0);
  9092.       op1 = force_not_mem (op1);
  9093.     }
  9094.  
  9095.   do_pending_stack_adjust ();
  9096.  
  9097.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT
  9098.       && (tem = simplify_relational_operation (code, mode, op0, op1)) != 0)
  9099.     return tem;
  9100.  
  9101. #if 0
  9102.   /* There's no need to do this now that combine.c can eliminate lots of
  9103.      sign extensions.  This can be less efficient in certain cases on other
  9104.      machines. */
  9105.  
  9106.   /* If this is a signed equality comparison, we can do it as an
  9107.      unsigned comparison since zero-extension is cheaper than sign
  9108.      extension and comparisons with zero are done as unsigned.  This is
  9109.      the case even on machines that can do fast sign extension, since
  9110.      zero-extension is easier to combine with other operations than
  9111.      sign-extension is.  If we are comparing against a constant, we must
  9112.      convert it to what it would look like unsigned.  */
  9113.   if ((code == EQ || code == NE) && ! unsignedp
  9114.       && GET_MODE_BITSIZE (GET_MODE (op0)) <= HOST_BITS_PER_WIDE_INT)
  9115.     {
  9116.       if (GET_CODE (op1) == CONST_INT
  9117.       && (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0))) != INTVAL (op1))
  9118.     op1 = GEN_INT (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0)));
  9119.       unsignedp = 1;
  9120.     }
  9121. #endif
  9122.     
  9123.   emit_cmp_insn (op0, op1, code, size, mode, unsignedp, align);
  9124.  
  9125.   return gen_rtx (code, VOIDmode, cc0_rtx, const0_rtx);
  9126. }
  9127.  
  9128. /* Generate code to calculate EXP using a store-flag instruction
  9129.    and return an rtx for the result.  EXP is either a comparison
  9130.    or a TRUTH_NOT_EXPR whose operand is a comparison.
  9131.  
  9132.    If TARGET is nonzero, store the result there if convenient.
  9133.  
  9134.    If ONLY_CHEAP is non-zero, only do this if it is likely to be very
  9135.    cheap.
  9136.  
  9137.    Return zero if there is no suitable set-flag instruction
  9138.    available on this machine.
  9139.  
  9140.    Once expand_expr has been called on the arguments of the comparison,
  9141.    we are committed to doing the store flag, since it is not safe to
  9142.    re-evaluate the expression.  We emit the store-flag insn by calling
  9143.    emit_store_flag, but only expand the arguments if we have a reason
  9144.    to believe that emit_store_flag will be successful.  If we think that
  9145.    it will, but it isn't, we have to simulate the store-flag with a
  9146.    set/jump/set sequence.  */
  9147.  
  9148. static rtx
  9149. do_store_flag (exp, target, mode, only_cheap)
  9150.      tree exp;
  9151.      rtx target;
  9152.      enum machine_mode mode;
  9153.      int only_cheap;
  9154. {
  9155.   enum rtx_code code;
  9156.   tree arg0, arg1, type;
  9157.   tree tem;
  9158.   enum machine_mode operand_mode;
  9159.   int invert = 0;
  9160.   int unsignedp;
  9161.   rtx op0, op1;
  9162.   enum insn_code icode;
  9163.   rtx subtarget = target;
  9164.   rtx result, label, pattern, jump_pat;
  9165.  
  9166.   /* If this is a TRUTH_NOT_EXPR, set a flag indicating we must invert the
  9167.      result at the end.  We can't simply invert the test since it would
  9168.      have already been inverted if it were valid.  This case occurs for
  9169.      some floating-point comparisons.  */
  9170.  
  9171.   if (TREE_CODE (exp) == TRUTH_NOT_EXPR)
  9172.     invert = 1, exp = TREE_OPERAND (exp, 0);
  9173.  
  9174.   arg0 = TREE_OPERAND (exp, 0);
  9175.   arg1 = TREE_OPERAND (exp, 1);
  9176.   type = TREE_TYPE (arg0);
  9177.   operand_mode = TYPE_MODE (type);
  9178.   unsignedp = TREE_UNSIGNED (type);
  9179.  
  9180.   /* We won't bother with BLKmode store-flag operations because it would mean
  9181.      passing a lot of information to emit_store_flag.  */
  9182.   if (operand_mode == BLKmode)
  9183.     return 0;
  9184.  
  9185.   STRIP_NOPS (arg0);
  9186.   STRIP_NOPS (arg1);
  9187.  
  9188.   /* Get the rtx comparison code to use.  We know that EXP is a comparison
  9189.      operation of some type.  Some comparisons against 1 and -1 can be
  9190.      converted to comparisons with zero.  Do so here so that the tests
  9191.      below will be aware that we have a comparison with zero.   These
  9192.      tests will not catch constants in the first operand, but constants
  9193.      are rarely passed as the first operand.  */
  9194.  
  9195.   switch (TREE_CODE (exp))
  9196.     {
  9197.     case EQ_EXPR:
  9198.       code = EQ;
  9199.       break;
  9200.     case NE_EXPR:
  9201.       code = NE;
  9202.       break;
  9203.     case LT_EXPR:
  9204.       if (integer_onep (arg1))
  9205.     arg1 = integer_zero_node, code = unsignedp ? LEU : LE;
  9206.       else
  9207.     code = unsignedp ? LTU : LT;
  9208.       break;
  9209.     case LE_EXPR:
  9210.       if (! unsignedp && integer_all_onesp (arg1))
  9211.     arg1 = integer_zero_node, code = LT;
  9212.       else
  9213.     code = unsignedp ? LEU : LE;
  9214.       break;
  9215.     case GT_EXPR:
  9216.       if (! unsignedp && integer_all_onesp (arg1))
  9217.     arg1 = integer_zero_node, code = GE;
  9218.       else
  9219.     code = unsignedp ? GTU : GT;
  9220.       break;
  9221.     case GE_EXPR:
  9222.       if (integer_onep (arg1))
  9223.     arg1 = integer_zero_node, code = unsignedp ? GTU : GT;
  9224.       else
  9225.     code = unsignedp ? GEU : GE;
  9226.       break;
  9227.     default:
  9228.       abort ();
  9229.     }
  9230.  
  9231.   /* Put a constant second.  */
  9232.   if (TREE_CODE (arg0) == REAL_CST || TREE_CODE (arg0) == INTEGER_CST)
  9233.     {
  9234.       tem = arg0; arg0 = arg1; arg1 = tem;
  9235.       code = swap_condition (code);
  9236.     }
  9237.  
  9238.   /* If this is an equality or inequality test of a single bit, we can
  9239.      do this by shifting the bit being tested to the low-order bit and
  9240.      masking the result with the constant 1.  If the condition was EQ,
  9241.      we xor it with 1.  This does not require an scc insn and is faster
  9242.      than an scc insn even if we have it.  */
  9243.  
  9244.   if ((code == NE || code == EQ)
  9245.       && TREE_CODE (arg0) == BIT_AND_EXPR && integer_zerop (arg1)
  9246.       && integer_pow2p (TREE_OPERAND (arg0, 1))
  9247.       && TYPE_PRECISION (type) <= HOST_BITS_PER_WIDE_INT)
  9248.     {
  9249.       tree inner = TREE_OPERAND (arg0, 0);
  9250.       int bitnum = exact_log2 (INTVAL (expand_expr (TREE_OPERAND (arg0, 1),
  9251.                             NULL_RTX, VOIDmode, 0)));
  9252.       int ops_unsignedp;
  9253.  
  9254.       /* If INNER is a right shift of a constant and it plus BITNUM does
  9255.      not overflow, adjust BITNUM and INNER.  */
  9256.  
  9257.       if (TREE_CODE (inner) == RSHIFT_EXPR
  9258.       && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST
  9259.       && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0
  9260.       && (bitnum + TREE_INT_CST_LOW (TREE_OPERAND (inner, 1))
  9261.           < TYPE_PRECISION (type)))
  9262.     {
  9263.       bitnum +=TREE_INT_CST_LOW (TREE_OPERAND (inner, 1));
  9264.       inner = TREE_OPERAND (inner, 0);
  9265.     }
  9266.  
  9267.       /* If we are going to be able to omit the AND below, we must do our
  9268.      operations as unsigned.  If we must use the AND, we have a choice.
  9269.      Normally unsigned is faster, but for some machines signed is.  */
  9270.       ops_unsignedp = (bitnum == TYPE_PRECISION (type) - 1 ? 1
  9271. #ifdef LOAD_EXTEND_OP
  9272.                : (LOAD_EXTEND_OP (operand_mode) == SIGN_EXTEND ? 0 : 1)
  9273. #else
  9274.                : 1
  9275. #endif
  9276.                );
  9277.  
  9278.       if (subtarget == 0 || GET_CODE (subtarget) != REG
  9279.       || GET_MODE (subtarget) != operand_mode
  9280.       || ! safe_from_p (subtarget, inner))
  9281.     subtarget = 0;
  9282.  
  9283.       op0 = expand_expr (inner, subtarget, VOIDmode, 0);
  9284.  
  9285.       if (bitnum != 0)
  9286.     op0 = expand_shift (RSHIFT_EXPR, GET_MODE (op0), op0,
  9287.                 size_int (bitnum), subtarget, ops_unsignedp);
  9288.  
  9289.       if (GET_MODE (op0) != mode)
  9290.     op0 = convert_to_mode (mode, op0, ops_unsignedp);
  9291.  
  9292.       if ((code == EQ && ! invert) || (code == NE && invert))
  9293.     op0 = expand_binop (mode, xor_optab, op0, const1_rtx, subtarget,
  9294.                 ops_unsignedp, OPTAB_LIB_WIDEN);
  9295.  
  9296.       /* Put the AND last so it can combine with more things.  */
  9297.       if (bitnum != TYPE_PRECISION (type) - 1)
  9298.     op0 = expand_and (op0, const1_rtx, subtarget);
  9299.  
  9300.       return op0;
  9301.     }
  9302.  
  9303.   /* Now see if we are likely to be able to do this.  Return if not.  */
  9304.   if (! can_compare_p (operand_mode))
  9305.     return 0;
  9306.   icode = setcc_gen_code[(int) code];
  9307.   if (icode == CODE_FOR_nothing
  9308.       || (only_cheap && insn_operand_mode[(int) icode][0] != mode))
  9309.     {
  9310.       /* We can only do this if it is one of the special cases that
  9311.      can be handled without an scc insn.  */
  9312.       if ((code == LT && integer_zerop (arg1))
  9313.       || (! only_cheap && code == GE && integer_zerop (arg1)))
  9314.     ;
  9315.       else if (BRANCH_COST >= 0
  9316.            && ! only_cheap && (code == NE || code == EQ)
  9317.            && TREE_CODE (type) != REAL_TYPE
  9318.            && ((abs_optab->handlers[(int) operand_mode].insn_code
  9319.             != CODE_FOR_nothing)
  9320.            || (ffs_optab->handlers[(int) operand_mode].insn_code
  9321.                != CODE_FOR_nothing)))
  9322.     ;
  9323.       else
  9324.     return 0;
  9325.     }
  9326.       
  9327.   preexpand_calls (exp);
  9328.   if (subtarget == 0 || GET_CODE (subtarget) != REG
  9329.       || GET_MODE (subtarget) != operand_mode
  9330.       || ! safe_from_p (subtarget, arg1))
  9331.     subtarget = 0;
  9332.  
  9333.   op0 = expand_expr (arg0, subtarget, VOIDmode, 0);
  9334.   op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
  9335.  
  9336.   if (target == 0)
  9337.     target = gen_reg_rtx (mode);
  9338.  
  9339.   /* Pass copies of OP0 and OP1 in case they contain a QUEUED.  This is safe
  9340.      because, if the emit_store_flag does anything it will succeed and
  9341.      OP0 and OP1 will not be used subsequently.  */
  9342.  
  9343.   result = emit_store_flag (target, code,
  9344.                 queued_subexp_p (op0) ? copy_rtx (op0) : op0,
  9345.                 queued_subexp_p (op1) ? copy_rtx (op1) : op1,
  9346.                 operand_mode, unsignedp, 1);
  9347.  
  9348.   if (result)
  9349.     {
  9350.       if (invert)
  9351.     result = expand_binop (mode, xor_optab, result, const1_rtx,
  9352.                    result, 0, OPTAB_LIB_WIDEN);
  9353.       return result;
  9354.     }
  9355.  
  9356.   /* If this failed, we have to do this with set/compare/jump/set code.  */
  9357.   if (target == 0 || GET_CODE (target) != REG
  9358.       || reg_mentioned_p (target, op0) || reg_mentioned_p (target, op1))
  9359.     target = gen_reg_rtx (GET_MODE (target));
  9360.  
  9361.   emit_move_insn (target, invert ? const0_rtx : const1_rtx);
  9362.   result = compare_from_rtx (op0, op1, code, unsignedp,
  9363.                  operand_mode, NULL_RTX, 0);
  9364.   if (GET_CODE (result) == CONST_INT)
  9365.     return (((result == const0_rtx && ! invert)
  9366.          || (result != const0_rtx && invert))
  9367.         ? const0_rtx : const1_rtx);
  9368.  
  9369.   label = gen_label_rtx ();
  9370.   if (bcc_gen_fctn[(int) code] == 0)
  9371.     abort ();
  9372.  
  9373.   emit_jump_insn ((*bcc_gen_fctn[(int) code]) (label));
  9374.   emit_move_insn (target, invert ? const1_rtx : const0_rtx);
  9375.   emit_label (label);
  9376.  
  9377.   return target;
  9378. }
  9379.  
  9380. /* Generate a tablejump instruction (used for switch statements).  */
  9381.  
  9382. #ifdef HAVE_tablejump
  9383.  
  9384. /* INDEX is the value being switched on, with the lowest value
  9385.    in the table already subtracted.
  9386.    MODE is its expected mode (needed if INDEX is constant).
  9387.    RANGE is the length of the jump table.
  9388.    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
  9389.  
  9390.    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
  9391.    index value is out of range.  */
  9392.  
  9393. void
  9394. do_tablejump (index, mode, range, table_label, default_label)
  9395.      rtx index, range, table_label, default_label;
  9396.      enum machine_mode mode;
  9397. {
  9398.   register rtx temp, vector;
  9399.  
  9400.   /* Do an unsigned comparison (in the proper mode) between the index
  9401.      expression and the value which represents the length of the range.
  9402.      Since we just finished subtracting the lower bound of the range
  9403.      from the index expression, this comparison allows us to simultaneously
  9404.      check that the original index expression value is both greater than
  9405.      or equal to the minimum value of the range and less than or equal to
  9406.      the maximum value of the range.  */
  9407.  
  9408.   emit_cmp_insn (index, range, GTU, NULL_RTX, mode, 1, 0);
  9409.   emit_jump_insn (gen_bgtu (default_label));
  9410.  
  9411.   /* If index is in range, it must fit in Pmode.
  9412.      Convert to Pmode so we can index with it.  */
  9413.   if (mode != Pmode)
  9414.     index = convert_to_mode (Pmode, index, 1);
  9415.  
  9416.   /* Don't let a MEM slip thru, because then INDEX that comes
  9417.      out of PIC_CASE_VECTOR_ADDRESS won't be a valid address,
  9418.      and break_out_memory_refs will go to work on it and mess it up.  */
  9419. #ifdef PIC_CASE_VECTOR_ADDRESS
  9420.   if (flag_pic && GET_CODE (index) != REG)
  9421.     index = copy_to_mode_reg (Pmode, index);
  9422. #endif
  9423.  
  9424.   /* If flag_force_addr were to affect this address
  9425.      it could interfere with the tricky assumptions made
  9426.      about addresses that contain label-refs,
  9427.      which may be valid only very near the tablejump itself.  */
  9428.   /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
  9429.      GET_MODE_SIZE, because this indicates how large insns are.  The other
  9430.      uses should all be Pmode, because they are addresses.  This code
  9431.      could fail if addresses and insns are not the same size.  */
  9432.   index = gen_rtx (PLUS, Pmode,
  9433.            gen_rtx (MULT, Pmode, index,
  9434.                 GEN_INT (GET_MODE_SIZE (CASE_VECTOR_MODE))),
  9435.            gen_rtx (LABEL_REF, Pmode, table_label));
  9436. #ifdef PIC_CASE_VECTOR_ADDRESS
  9437.   if (flag_pic)
  9438.     index = PIC_CASE_VECTOR_ADDRESS (index);
  9439.   else
  9440. #endif
  9441.     index = memory_address_noforce (CASE_VECTOR_MODE, index);
  9442.   temp = gen_reg_rtx (CASE_VECTOR_MODE);
  9443.   vector = gen_rtx (MEM, CASE_VECTOR_MODE, index);
  9444.   RTX_UNCHANGING_P (vector) = 1;
  9445.   convert_move (temp, vector, 0);
  9446.  
  9447.   emit_jump_insn (gen_tablejump (temp, table_label));
  9448.  
  9449. #ifndef CASE_VECTOR_PC_RELATIVE
  9450.   /* If we are generating PIC code or if the table is PC-relative, the
  9451.      table and JUMP_INSN must be adjacent, so don't output a BARRIER.  */
  9452.   if (! flag_pic)
  9453.     emit_barrier ();
  9454. #endif
  9455. }
  9456.  
  9457. #endif /* HAVE_tablejump */
  9458.  
  9459.  
  9460. /* Emit a suitable bytecode to load a value from memory, assuming a pointer
  9461.    to that value is on the top of the stack. The resulting type is TYPE, and
  9462.    the source declaration is DECL. */
  9463.  
  9464. void
  9465. bc_load_memory (type, decl)
  9466.      tree type, decl;
  9467. {
  9468.   enum bytecode_opcode opcode;
  9469.   
  9470.   
  9471.   /* Bit fields are special.  We only know about signed and
  9472.      unsigned ints, and enums.  The latter are treated as
  9473.      signed integers. */
  9474.   
  9475.   if (DECL_BIT_FIELD (decl))
  9476.     if (TREE_CODE (type) == ENUMERAL_TYPE
  9477.     || TREE_CODE (type) == INTEGER_TYPE)
  9478.       opcode = TREE_UNSIGNED (type) ? zxloadBI : sxloadBI;
  9479.     else
  9480.       abort ();
  9481.   else
  9482.     /* See corresponding comment in bc_store_memory(). */
  9483.     if (TYPE_MODE (type) == BLKmode
  9484.     || TYPE_MODE (type) == VOIDmode)
  9485.       return;
  9486.     else
  9487.       opcode = mode_to_load_map [(int) TYPE_MODE (type)];
  9488.  
  9489.   if (opcode == neverneverland)
  9490.     abort ();
  9491.   
  9492.   bc_emit_bytecode (opcode);
  9493.   
  9494. #ifdef DEBUG_PRINT_CODE
  9495.   fputc ('\n', stderr);
  9496. #endif
  9497. }
  9498.  
  9499.  
  9500. /* Store the contents of the second stack slot to the address in the
  9501.    top stack slot.  DECL is the declaration of the destination and is used
  9502.    to determine whether we're dealing with a bitfield. */
  9503.  
  9504. void
  9505. bc_store_memory (type, decl)
  9506.      tree type, decl;
  9507. {
  9508.   enum bytecode_opcode opcode;
  9509.   
  9510.   
  9511.   if (DECL_BIT_FIELD (decl))
  9512.     {
  9513.       if (TREE_CODE (type) == ENUMERAL_TYPE
  9514.       || TREE_CODE (type) == INTEGER_TYPE)
  9515.     opcode = sstoreBI;
  9516.       else
  9517.     abort ();
  9518.     }
  9519.   else
  9520.     if (TYPE_MODE (type) == BLKmode)
  9521.       {
  9522.     /* Copy structure.  This expands to a block copy instruction, storeBLK.
  9523.        In addition to the arguments expected by the other store instructions,
  9524.        it also expects a type size (SImode) on top of the stack, which is the
  9525.        structure size in size units (usually bytes).  The two first arguments
  9526.        are already on the stack; so we just put the size on level 1.  For some
  9527.        other languages, the size may be variable, this is why we don't encode
  9528.        it as a storeBLK literal, but rather treat it as a full-fledged expression. */
  9529.     
  9530.     bc_expand_expr (TYPE_SIZE (type));
  9531.     opcode = storeBLK;
  9532.       }
  9533.     else
  9534.       opcode = mode_to_store_map [(int) TYPE_MODE (type)];
  9535.  
  9536.   if (opcode == neverneverland)
  9537.     abort ();
  9538.  
  9539.   bc_emit_bytecode (opcode);
  9540.   
  9541. #ifdef DEBUG_PRINT_CODE
  9542.   fputc ('\n', stderr);
  9543. #endif
  9544. }
  9545.  
  9546.  
  9547. /* Allocate local stack space sufficient to hold a value of the given
  9548.    SIZE at alignment boundary ALIGNMENT bits.  ALIGNMENT must be an
  9549.    integral power of 2.  A special case is locals of type VOID, which
  9550.    have size 0 and alignment 1 - any "voidish" SIZE or ALIGNMENT is
  9551.    remapped into the corresponding attribute of SI.  */
  9552.  
  9553. rtx
  9554. bc_allocate_local (size, alignment)
  9555.      int size, alignment;
  9556. {
  9557.   rtx retval;
  9558.   int byte_alignment;
  9559.  
  9560.   if (size < 0)
  9561.     abort ();
  9562.  
  9563.   /* Normalize size and alignment  */
  9564.   if (!size)
  9565.     size = UNITS_PER_WORD;
  9566.  
  9567.   if (alignment < BITS_PER_UNIT)
  9568.     byte_alignment = 1 << (INT_ALIGN - 1);
  9569.   else
  9570.     /* Align */
  9571.     byte_alignment = alignment / BITS_PER_UNIT;
  9572.  
  9573.   if (local_vars_size & (byte_alignment - 1))
  9574.     local_vars_size += byte_alignment - (local_vars_size & (byte_alignment - 1));
  9575.  
  9576.   retval = bc_gen_rtx ((char *) 0, local_vars_size, (struct bc_label *) 0);
  9577.   local_vars_size += size;
  9578.  
  9579.   return retval;
  9580. }
  9581.  
  9582.  
  9583. /* Allocate variable-sized local array. Variable-sized arrays are
  9584.    actually pointers to the address in memory where they are stored. */
  9585.  
  9586. rtx
  9587. bc_allocate_variable_array (size)
  9588.      tree size;
  9589. {
  9590.   rtx retval;
  9591.   const int ptralign = (1 << (PTR_ALIGN - 1));
  9592.  
  9593.   /* Align pointer */
  9594.   if (local_vars_size & ptralign)
  9595.     local_vars_size +=  ptralign - (local_vars_size & ptralign);
  9596.  
  9597.   /* Note down local space needed: pointer to block; also return
  9598.      dummy rtx */
  9599.  
  9600.   retval = bc_gen_rtx ((char *) 0, local_vars_size, (struct bc_label *) 0);
  9601.   local_vars_size += POINTER_SIZE / BITS_PER_UNIT;
  9602.   return retval;
  9603. }
  9604.  
  9605.  
  9606. /* Push the machine address for the given external variable offset.  */
  9607. void
  9608. bc_load_externaddr (externaddr)
  9609.      rtx externaddr;
  9610. {
  9611.   bc_emit_bytecode (constP);
  9612.   bc_emit_code_labelref (BYTECODE_LABEL (externaddr),
  9613.              BYTECODE_BC_LABEL (externaddr)->offset);
  9614.  
  9615. #ifdef DEBUG_PRINT_CODE
  9616.   fputc ('\n', stderr);
  9617. #endif
  9618. }
  9619.  
  9620.  
  9621. static char *
  9622. bc_strdup (s)
  9623.     char *s;
  9624. {
  9625.   char *new = (char *) xmalloc ((strlen (s) + 1) * sizeof *s);
  9626.   strcpy (new, s);
  9627.   return new;
  9628. }
  9629.  
  9630.  
  9631. /* Like above, but expects an IDENTIFIER.  */
  9632. void
  9633. bc_load_externaddr_id (id, offset)
  9634.      tree id;
  9635.      int offset;
  9636. {
  9637.   if (!IDENTIFIER_POINTER (id))
  9638.     abort ();
  9639.  
  9640.   bc_emit_bytecode (constP);
  9641.   bc_emit_code_labelref (bc_xstrdup (IDENTIFIER_POINTER (id)), offset);
  9642.  
  9643. #ifdef DEBUG_PRINT_CODE
  9644.   fputc ('\n', stderr);
  9645. #endif
  9646. }
  9647.  
  9648.  
  9649. /* Push the machine address for the given local variable offset.  */
  9650. void
  9651. bc_load_localaddr (localaddr)
  9652.      rtx localaddr;
  9653. {
  9654.   bc_emit_instruction (localP, (HOST_WIDE_INT) BYTECODE_BC_LABEL (localaddr)->offset);
  9655. }
  9656.  
  9657.  
  9658. /* Push the machine address for the given parameter offset.
  9659.    NOTE: offset is in bits. */
  9660. void
  9661. bc_load_parmaddr (parmaddr)
  9662.      rtx parmaddr;
  9663. {
  9664.   bc_emit_instruction (argP, ((HOST_WIDE_INT) BYTECODE_BC_LABEL (parmaddr)->offset
  9665.                   / BITS_PER_UNIT));
  9666. }
  9667.  
  9668.  
  9669. /* Convert a[i] into *(a + i).  */
  9670. tree
  9671. bc_canonicalize_array_ref (exp)
  9672.      tree exp;
  9673. {
  9674.   tree type = TREE_TYPE (exp);
  9675.   tree array_adr = build1 (ADDR_EXPR, TYPE_POINTER_TO (type),
  9676.                TREE_OPERAND (exp, 0));
  9677.   tree index = TREE_OPERAND (exp, 1);
  9678.  
  9679.  
  9680.   /* Convert the integer argument to a type the same size as a pointer
  9681.      so the multiply won't overflow spuriously.  */
  9682.  
  9683.   if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
  9684.     index = convert (type_for_size (POINTER_SIZE, 0), index);
  9685.  
  9686.   /* The array address isn't volatile even if the array is.
  9687.      (Of course this isn't terribly relevant since the bytecode
  9688.      translator treats nearly everything as volatile anyway.)  */
  9689.   TREE_THIS_VOLATILE (array_adr) = 0;
  9690.  
  9691.   return build1 (INDIRECT_REF, type,
  9692.          fold (build (PLUS_EXPR,
  9693.                   TYPE_POINTER_TO (type),
  9694.                   array_adr,
  9695.                   fold (build (MULT_EXPR,
  9696.                        TYPE_POINTER_TO (type),
  9697.                        index,
  9698.                        size_in_bytes (type))))));
  9699. }
  9700.  
  9701.  
  9702. /* Load the address of the component referenced by the given
  9703.    COMPONENT_REF expression.
  9704.  
  9705.    Returns innermost lvalue. */
  9706.  
  9707. tree
  9708. bc_expand_component_address (exp)
  9709.      tree exp;
  9710. {
  9711.   tree tem, chain;
  9712.   enum machine_mode mode;
  9713.   int bitpos = 0;
  9714.   HOST_WIDE_INT SIval;
  9715.  
  9716.  
  9717.   tem = TREE_OPERAND (exp, 1);
  9718.   mode = DECL_MODE (tem);
  9719.  
  9720.  
  9721.   /* Compute cumulative bit offset for nested component refs
  9722.      and array refs, and find the ultimate containing object.  */
  9723.  
  9724.   for (tem = exp;; tem = TREE_OPERAND (tem, 0))
  9725.     {
  9726.       if (TREE_CODE (tem) == COMPONENT_REF)
  9727.     bitpos += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (tem, 1)));
  9728.       else
  9729.     if (TREE_CODE (tem) == ARRAY_REF
  9730.         && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  9731.         && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  9732.  
  9733.       bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  9734.              * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  9735.              /* * TYPE_SIZE_UNIT (TREE_TYPE (tem)) */);
  9736.     else
  9737.       break;
  9738.     }
  9739.  
  9740.   bc_expand_expr (tem);
  9741.  
  9742.  
  9743.   /* For bitfields also push their offset and size */
  9744.   if (DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  9745.     bc_push_offset_and_size (bitpos, /* DECL_SIZE_UNIT */ (TREE_OPERAND (exp, 1)));
  9746.   else
  9747.     if (SIval = bitpos / BITS_PER_UNIT)
  9748.       bc_emit_instruction (addconstPSI, SIval);
  9749.  
  9750.   return (TREE_OPERAND (exp, 1));
  9751. }
  9752.  
  9753.  
  9754. /* Emit code to push two SI constants */
  9755. void
  9756. bc_push_offset_and_size (offset, size)
  9757.      HOST_WIDE_INT offset, size;
  9758. {
  9759.   bc_emit_instruction (constSI, offset);
  9760.   bc_emit_instruction (constSI, size);
  9761. }
  9762.  
  9763.  
  9764. /* Emit byte code to push the address of the given lvalue expression to
  9765.    the stack.  If it's a bit field, we also push offset and size info.
  9766.  
  9767.    Returns innermost component, which allows us to determine not only
  9768.    its type, but also whether it's a bitfield. */
  9769.  
  9770. tree
  9771. bc_expand_address (exp)
  9772.      tree exp;
  9773. {
  9774.   /* Safeguard */
  9775.   if (!exp || TREE_CODE (exp) == ERROR_MARK)
  9776.     return (exp);
  9777.  
  9778.  
  9779.   switch (TREE_CODE (exp))
  9780.     {
  9781.     case ARRAY_REF:
  9782.  
  9783.       return (bc_expand_address (bc_canonicalize_array_ref (exp)));
  9784.  
  9785.     case COMPONENT_REF:
  9786.  
  9787.       return (bc_expand_component_address (exp));
  9788.  
  9789.     case INDIRECT_REF:
  9790.  
  9791.       bc_expand_expr (TREE_OPERAND (exp, 0));
  9792.  
  9793.       /* For variable-sized types: retrieve pointer.  Sometimes the
  9794.      TYPE_SIZE tree is NULL.  Is this a bug or a feature?  Let's
  9795.      also make sure we have an operand, just in case... */
  9796.  
  9797.       if (TREE_OPERAND (exp, 0)
  9798.       && TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)))
  9799.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)))) != INTEGER_CST)
  9800.     bc_emit_instruction (loadP);
  9801.  
  9802.       /* If packed, also return offset and size */
  9803.       if (DECL_BIT_FIELD (TREE_OPERAND (exp, 0)))
  9804.     
  9805.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (exp, 0))),
  9806.                  TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (exp, 0))));
  9807.  
  9808.       return (TREE_OPERAND (exp, 0));
  9809.  
  9810.     case FUNCTION_DECL:
  9811.  
  9812.       bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  9813.                  BYTECODE_BC_LABEL (DECL_RTL (exp))->offset);
  9814.       break;
  9815.  
  9816.     case PARM_DECL:
  9817.  
  9818.       bc_load_parmaddr (DECL_RTL (exp));
  9819.  
  9820.       /* For variable-sized types: retrieve pointer */
  9821.       if (TYPE_SIZE (TREE_TYPE (exp))
  9822.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  9823.     bc_emit_instruction (loadP);
  9824.  
  9825.       /* If packed, also return offset and size */
  9826.       if (DECL_BIT_FIELD (exp))
  9827.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (exp)),
  9828.                  TREE_INT_CST_LOW (DECL_SIZE (exp)));
  9829.  
  9830.       break;
  9831.  
  9832.     case RESULT_DECL:
  9833.  
  9834.       bc_emit_instruction (returnP);
  9835.       break;
  9836.  
  9837.     case VAR_DECL:
  9838.  
  9839. #if 0
  9840.       if (BYTECODE_LABEL (DECL_RTL (exp)))
  9841.     bc_load_externaddr (DECL_RTL (exp));
  9842. #endif
  9843.  
  9844.       if (DECL_EXTERNAL (exp))
  9845.     bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  9846.                    (BYTECODE_BC_LABEL (DECL_RTL (exp)))->offset);
  9847.       else
  9848.     bc_load_localaddr (DECL_RTL (exp));
  9849.  
  9850.       /* For variable-sized types: retrieve pointer */
  9851.       if (TYPE_SIZE (TREE_TYPE (exp))
  9852.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  9853.     bc_emit_instruction (loadP);
  9854.  
  9855.       /* If packed, also return offset and size */
  9856.       if (DECL_BIT_FIELD (exp))
  9857.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (exp)),
  9858.                  TREE_INT_CST_LOW (DECL_SIZE (exp)));
  9859.       
  9860.       break;
  9861.  
  9862.     case STRING_CST:
  9863.       {
  9864.     rtx r;
  9865.     
  9866.     bc_emit_bytecode (constP);
  9867.     r = output_constant_def (exp);
  9868.     bc_emit_code_labelref (BYTECODE_LABEL (r), BYTECODE_BC_LABEL (r)->offset);
  9869.  
  9870. #ifdef DEBUG_PRINT_CODE
  9871.     fputc ('\n', stderr);
  9872. #endif
  9873.       }
  9874.       break;
  9875.  
  9876.     default:
  9877.  
  9878.       abort();
  9879.       break;
  9880.     }
  9881.  
  9882.   /* Most lvalues don't have components. */
  9883.   return (exp);
  9884. }
  9885.  
  9886.  
  9887. /* Emit a type code to be used by the runtime support in handling
  9888.    parameter passing.   The type code consists of the machine mode
  9889.    plus the minimal alignment shifted left 8 bits.  */
  9890.  
  9891. tree
  9892. bc_runtime_type_code (type)
  9893.      tree type;
  9894. {
  9895.   int val;
  9896.  
  9897.   switch (TREE_CODE (type))
  9898.     {
  9899.     case VOID_TYPE:
  9900.     case INTEGER_TYPE:
  9901.     case REAL_TYPE:
  9902.     case COMPLEX_TYPE:
  9903.     case ENUMERAL_TYPE:
  9904.     case POINTER_TYPE:
  9905.     case RECORD_TYPE:
  9906.  
  9907.       val = (int) TYPE_MODE (type) | TYPE_ALIGN (type) << 8;
  9908.       break;
  9909.  
  9910.     case ERROR_MARK:
  9911.  
  9912.       val = 0;
  9913.       break;
  9914.  
  9915.     default:
  9916.  
  9917.       abort ();
  9918.     }
  9919.   return build_int_2 (val, 0);
  9920. }
  9921.  
  9922.  
  9923. /* Generate constructor label */
  9924. char *
  9925. bc_gen_constr_label ()
  9926. {
  9927.   static int label_counter;
  9928.   static char label[20];
  9929.  
  9930.   sprintf (label, "*LR%d", label_counter++);
  9931.  
  9932.   return (obstack_copy0 (&permanent_obstack, label, strlen (label)));
  9933. }
  9934.  
  9935.  
  9936. /* Evaluate constructor CONSTR and return pointer to it on level one.  We
  9937.    expand the constructor data as static data, and push a pointer to it.
  9938.    The pointer is put in the pointer table and is retrieved by a constP
  9939.    bytecode instruction.  We then loop and store each constructor member in
  9940.    the corresponding component.  Finally, we return the original pointer on
  9941.    the stack. */
  9942.  
  9943. void
  9944. bc_expand_constructor (constr)
  9945.      tree constr;
  9946. {
  9947.   char *l;
  9948.   HOST_WIDE_INT ptroffs;
  9949.   rtx constr_rtx;
  9950.  
  9951.   
  9952.   /* Literal constructors are handled as constants, whereas
  9953.      non-literals are evaluated and stored element by element
  9954.      into the data segment. */
  9955.   
  9956.   /* Allocate space in proper segment and push pointer to space on stack.
  9957.    */
  9958.  
  9959.   l = bc_gen_constr_label ();
  9960.  
  9961.   if (TREE_CONSTANT (constr))
  9962.     {
  9963.       text_section ();
  9964.  
  9965.       bc_emit_const_labeldef (l);
  9966.       bc_output_constructor (constr, int_size_in_bytes (TREE_TYPE (constr)));
  9967.     }
  9968.   else
  9969.     {
  9970.       data_section ();
  9971.  
  9972.       bc_emit_data_labeldef (l);
  9973.       bc_output_data_constructor (constr);
  9974.     }
  9975.  
  9976.   
  9977.   /* Add reference to pointer table and recall pointer to stack;
  9978.      this code is common for both types of constructors: literals
  9979.      and non-literals. */
  9980.  
  9981.   ptroffs = bc_define_pointer (l);
  9982.   bc_emit_instruction (constP, ptroffs);
  9983.  
  9984.   /* This is all that has to be done if it's a literal. */
  9985.   if (TREE_CONSTANT (constr))
  9986.     return;
  9987.  
  9988.  
  9989.   /* At this point, we have the pointer to the structure on top of the stack.
  9990.      Generate sequences of store_memory calls for the constructor. */
  9991.   
  9992.   /* constructor type is structure */
  9993.   if (TREE_CODE (TREE_TYPE (constr)) == RECORD_TYPE)
  9994.     {
  9995.       register tree elt;
  9996.       
  9997.       /* If the constructor has fewer fields than the structure,
  9998.      clear the whole structure first.  */
  9999.       
  10000.       if (list_length (CONSTRUCTOR_ELTS (constr))
  10001.       != list_length (TYPE_FIELDS (TREE_TYPE (constr))))
  10002.     {
  10003.       bc_emit_instruction (duplicate);
  10004.       bc_emit_instruction (constSI, (HOST_WIDE_INT) int_size_in_bytes (TREE_TYPE (constr)));
  10005.       bc_emit_instruction (clearBLK);
  10006.     }
  10007.       
  10008.       /* Store each element of the constructor into the corresponding
  10009.      field of TARGET.  */
  10010.       
  10011.       for (elt = CONSTRUCTOR_ELTS (constr); elt; elt = TREE_CHAIN (elt))
  10012.     {
  10013.       register tree field = TREE_PURPOSE (elt);
  10014.       register enum machine_mode mode;
  10015.       int bitsize;
  10016.       int bitpos;
  10017.       int unsignedp;
  10018.       
  10019.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) /* * DECL_SIZE_UNIT (field) */;
  10020.       mode = DECL_MODE (field);
  10021.       unsignedp = TREE_UNSIGNED (field);
  10022.  
  10023.       bitpos = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  10024.       
  10025.       bc_store_field (elt, bitsize, bitpos, mode, TREE_VALUE (elt), TREE_TYPE (TREE_VALUE (elt)),
  10026.               /* The alignment of TARGET is
  10027.                  at least what its type requires.  */
  10028.               VOIDmode, 0,
  10029.               TYPE_ALIGN (TREE_TYPE (constr)) / BITS_PER_UNIT,
  10030.               int_size_in_bytes (TREE_TYPE (constr)));
  10031.     }
  10032.     }
  10033.   else
  10034.     
  10035.     /* Constructor type is array */
  10036.     if (TREE_CODE (TREE_TYPE (constr)) == ARRAY_TYPE)
  10037.       {
  10038.     register tree elt;
  10039.     register int i;
  10040.     tree domain = TYPE_DOMAIN (TREE_TYPE (constr));
  10041.     int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  10042.     int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  10043.     tree elttype = TREE_TYPE (TREE_TYPE (constr));
  10044.     
  10045.     /* If the constructor has fewer fields than the structure,
  10046.        clear the whole structure first.  */
  10047.     
  10048.     if (list_length (CONSTRUCTOR_ELTS (constr)) < maxelt - minelt + 1)
  10049.       {
  10050.         bc_emit_instruction (duplicate);
  10051.         bc_emit_instruction (constSI, (HOST_WIDE_INT) int_size_in_bytes (TREE_TYPE (constr)));
  10052.         bc_emit_instruction (clearBLK);
  10053.       }
  10054.     
  10055.     
  10056.     /* Store each element of the constructor into the corresponding
  10057.        element of TARGET, determined by counting the elements. */
  10058.     
  10059.     for (elt = CONSTRUCTOR_ELTS (constr), i = 0;
  10060.          elt;
  10061.          elt = TREE_CHAIN (elt), i++)
  10062.       {
  10063.         register enum machine_mode mode;
  10064.         int bitsize;
  10065.         int bitpos;
  10066.         int unsignedp;
  10067.         
  10068.         mode = TYPE_MODE (elttype);
  10069.         bitsize = GET_MODE_BITSIZE (mode);
  10070.         unsignedp = TREE_UNSIGNED (elttype);
  10071.         
  10072.         bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
  10073.               /* * TYPE_SIZE_UNIT (elttype) */ );
  10074.         
  10075.         bc_store_field (elt, bitsize, bitpos, mode,
  10076.                 TREE_VALUE (elt), TREE_TYPE (TREE_VALUE (elt)),
  10077.                 /* The alignment of TARGET is
  10078.                    at least what its type requires.  */
  10079.                 VOIDmode, 0,
  10080.                 TYPE_ALIGN (TREE_TYPE (constr)) / BITS_PER_UNIT,
  10081.                 int_size_in_bytes (TREE_TYPE (constr)));
  10082.       }
  10083.   
  10084.       }
  10085. }
  10086.  
  10087.  
  10088. /* Store the value of EXP (an expression tree) into member FIELD of
  10089.    structure at address on stack, which has type TYPE, mode MODE and
  10090.    occupies BITSIZE bits, starting BITPOS bits from the beginning of the
  10091.    structure.
  10092.  
  10093.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  10094.    TOTAL_SIZE is its size in bytes, or -1 if variable.  */
  10095.  
  10096. void
  10097. bc_store_field (field, bitsize, bitpos, mode, exp, type,
  10098.         value_mode, unsignedp, align, total_size)
  10099.      int bitsize, bitpos;
  10100.      enum machine_mode mode;
  10101.      tree field, exp, type;
  10102.      enum machine_mode value_mode;
  10103.      int unsignedp;
  10104.      int align;
  10105.      int total_size;
  10106. {
  10107.  
  10108.   /* Expand expression and copy pointer */
  10109.   bc_expand_expr (exp);
  10110.   bc_emit_instruction (over);
  10111.  
  10112.  
  10113.   /* If the component is a bit field, we cannot use addressing to access
  10114.      it.  Use bit-field techniques to store in it.  */
  10115.  
  10116.   if (DECL_BIT_FIELD (field))
  10117.     {
  10118.       bc_store_bit_field (bitpos, bitsize, unsignedp);
  10119.       return;
  10120.     }
  10121.   else
  10122.     /* Not bit field */
  10123.     {
  10124.       HOST_WIDE_INT offset = bitpos / BITS_PER_UNIT;
  10125.  
  10126.       /* Advance pointer to the desired member */
  10127.       if (offset)
  10128.     bc_emit_instruction (addconstPSI, offset);
  10129.  
  10130.       /* Store */
  10131.       bc_store_memory (type, field);
  10132.     }
  10133. }
  10134.  
  10135.  
  10136. /* Store SI/SU in bitfield */
  10137. void
  10138. bc_store_bit_field (offset, size, unsignedp)
  10139.      int offset, size, unsignedp;
  10140. {
  10141.   /* Push bitfield offset and size */
  10142.   bc_push_offset_and_size (offset, size);
  10143.  
  10144.   /* Store */
  10145.   bc_emit_instruction (sstoreBI);
  10146. }
  10147.  
  10148.  
  10149. /* Load SI/SU from bitfield */
  10150. void
  10151. bc_load_bit_field (offset, size, unsignedp)
  10152.      int offset, size, unsignedp;
  10153. {
  10154.   /* Push bitfield offset and size */
  10155.   bc_push_offset_and_size (offset, size);
  10156.  
  10157.   /* Load: sign-extend if signed, else zero-extend */
  10158.   bc_emit_instruction (unsignedp ? zxloadBI : sxloadBI);
  10159. }  
  10160.  
  10161.  
  10162. /* Adjust interpreter stack by NLEVELS.  Positive means drop NLEVELS
  10163.    (adjust stack pointer upwards), negative means add that number of
  10164.    levels (adjust the stack pointer downwards).  Only positive values
  10165.    normally make sense. */
  10166.  
  10167. void
  10168. bc_adjust_stack (nlevels)
  10169.      int nlevels;
  10170. {
  10171.   switch (nlevels)
  10172.     {
  10173.     case 0:
  10174.       break;
  10175.       
  10176.     case 2:
  10177.       bc_emit_instruction (drop);
  10178.       
  10179.     case 1:
  10180.       bc_emit_instruction (drop);
  10181.       break;
  10182.       
  10183.     default:
  10184.       
  10185.       bc_emit_instruction (adjstackSI, (HOST_WIDE_INT) nlevels);
  10186.       stack_depth -= nlevels;
  10187.     }
  10188.  
  10189. #if defined (VALIDATE_STACK_FOR_BC)
  10190.   VALIDATE_STACK_FOR_BC ();
  10191. #endif
  10192. }
  10193.